security/nss/lib/freebl/mpi/mpi_i86pc.s

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/mpi_i86pc.s	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,313 @@
     1.4 +/
     1.5 +/ This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +/ License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +/ file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +
     1.9 +.text
    1.10 +
    1.11 + /  ebp - 36:	caller's esi
    1.12 + /  ebp - 32:	caller's edi
    1.13 + /  ebp - 28:	
    1.14 + /  ebp - 24:	
    1.15 + /  ebp - 20:	
    1.16 + /  ebp - 16:	
    1.17 + /  ebp - 12:	
    1.18 + /  ebp - 8:	
    1.19 + /  ebp - 4:	
    1.20 + /  ebp + 0:	caller's ebp
    1.21 + /  ebp + 4:	return address
    1.22 + /  ebp + 8:	a	argument
    1.23 + /  ebp + 12:	a_len	argument
    1.24 + /  ebp + 16:	b	argument
    1.25 + /  ebp + 20:	c	argument
    1.26 + /  registers:
    1.27 + / 	eax:
    1.28 + /	ebx:	carry
    1.29 + /	ecx:	a_len
    1.30 + /	edx:
    1.31 + /	esi:	a ptr
    1.32 + /	edi:	c ptr
    1.33 +.globl	s_mpv_mul_d
    1.34 +.type	s_mpv_mul_d,@function
    1.35 +s_mpv_mul_d:
    1.36 +    push   %ebp
    1.37 +    mov    %esp,%ebp
    1.38 +    sub    $28,%esp
    1.39 +    push   %edi
    1.40 +    push   %esi
    1.41 +    push   %ebx
    1.42 +    movl   $0,%ebx		/ carry = 0
    1.43 +    mov    12(%ebp),%ecx	/ ecx = a_len
    1.44 +    mov    20(%ebp),%edi
    1.45 +    cmp    $0,%ecx
    1.46 +    je     L2			/ jmp if a_len == 0
    1.47 +    mov    8(%ebp),%esi		/ esi = a
    1.48 +    cld
    1.49 +L1:
    1.50 +    lodsl			/ eax = [ds:esi]; esi += 4
    1.51 +    mov    16(%ebp),%edx	/ edx = b
    1.52 +    mull   %edx			/ edx:eax = Phi:Plo = a_i * b
    1.53 +
    1.54 +    add    %ebx,%eax		/ add carry (%ebx) to edx:eax
    1.55 +    adc    $0,%edx
    1.56 +    mov    %edx,%ebx		/ high half of product becomes next carry
    1.57 +
    1.58 +    stosl			/ [es:edi] = ax; edi += 4;
    1.59 +    dec    %ecx			/ --a_len
    1.60 +    jnz    L1			/ jmp if a_len != 0
    1.61 +L2:
    1.62 +    mov    %ebx,0(%edi)		/ *c = carry
    1.63 +    pop    %ebx
    1.64 +    pop    %esi
    1.65 +    pop    %edi
    1.66 +    leave  
    1.67 +    ret    
    1.68 +    nop
    1.69 +
    1.70 + /  ebp - 36:	caller's esi
    1.71 + /  ebp - 32:	caller's edi
    1.72 + /  ebp - 28:	
    1.73 + /  ebp - 24:	
    1.74 + /  ebp - 20:	
    1.75 + /  ebp - 16:	
    1.76 + /  ebp - 12:	
    1.77 + /  ebp - 8:	
    1.78 + /  ebp - 4:	
    1.79 + /  ebp + 0:	caller's ebp
    1.80 + /  ebp + 4:	return address
    1.81 + /  ebp + 8:	a	argument
    1.82 + /  ebp + 12:	a_len	argument
    1.83 + /  ebp + 16:	b	argument
    1.84 + /  ebp + 20:	c	argument
    1.85 + /  registers:
    1.86 + / 	eax:
    1.87 + /	ebx:	carry
    1.88 + /	ecx:	a_len
    1.89 + /	edx:
    1.90 + /	esi:	a ptr
    1.91 + /	edi:	c ptr
    1.92 +.globl	s_mpv_mul_d_add
    1.93 +.type	s_mpv_mul_d_add,@function
    1.94 +s_mpv_mul_d_add:
    1.95 +    push   %ebp
    1.96 +    mov    %esp,%ebp
    1.97 +    sub    $28,%esp
    1.98 +    push   %edi
    1.99 +    push   %esi
   1.100 +    push   %ebx
   1.101 +    movl   $0,%ebx		/ carry = 0
   1.102 +    mov    12(%ebp),%ecx	/ ecx = a_len
   1.103 +    mov    20(%ebp),%edi
   1.104 +    cmp    $0,%ecx
   1.105 +    je     L4			/ jmp if a_len == 0
   1.106 +    mov    8(%ebp),%esi		/ esi = a
   1.107 +    cld
   1.108 +L3:
   1.109 +    lodsl			/ eax = [ds:esi]; esi += 4
   1.110 +    mov    16(%ebp),%edx	/ edx = b
   1.111 +    mull   %edx			/ edx:eax = Phi:Plo = a_i * b
   1.112 +
   1.113 +    add    %ebx,%eax		/ add carry (%ebx) to edx:eax
   1.114 +    adc    $0,%edx
   1.115 +    mov    0(%edi),%ebx		/ add in current word from *c
   1.116 +    add    %ebx,%eax		
   1.117 +    adc    $0,%edx
   1.118 +    mov    %edx,%ebx		/ high half of product becomes next carry
   1.119 +
   1.120 +    stosl			/ [es:edi] = ax; edi += 4;
   1.121 +    dec    %ecx			/ --a_len
   1.122 +    jnz    L3			/ jmp if a_len != 0
   1.123 +L4:
   1.124 +    mov    %ebx,0(%edi)		/ *c = carry
   1.125 +    pop    %ebx
   1.126 +    pop    %esi
   1.127 +    pop    %edi
   1.128 +    leave  
   1.129 +    ret    
   1.130 +    nop
   1.131 +
   1.132 + /  ebp - 36:	caller's esi
   1.133 + /  ebp - 32:	caller's edi
   1.134 + /  ebp - 28:	
   1.135 + /  ebp - 24:	
   1.136 + /  ebp - 20:	
   1.137 + /  ebp - 16:	
   1.138 + /  ebp - 12:	
   1.139 + /  ebp - 8:	
   1.140 + /  ebp - 4:	
   1.141 + /  ebp + 0:	caller's ebp
   1.142 + /  ebp + 4:	return address
   1.143 + /  ebp + 8:	a	argument
   1.144 + /  ebp + 12:	a_len	argument
   1.145 + /  ebp + 16:	b	argument
   1.146 + /  ebp + 20:	c	argument
   1.147 + /  registers:
   1.148 + / 	eax:
   1.149 + /	ebx:	carry
   1.150 + /	ecx:	a_len
   1.151 + /	edx:
   1.152 + /	esi:	a ptr
   1.153 + /	edi:	c ptr
   1.154 +.globl	s_mpv_mul_d_add_prop
   1.155 +.type	s_mpv_mul_d_add_prop,@function
   1.156 +s_mpv_mul_d_add_prop:
   1.157 +    push   %ebp
   1.158 +    mov    %esp,%ebp
   1.159 +    sub    $28,%esp
   1.160 +    push   %edi
   1.161 +    push   %esi
   1.162 +    push   %ebx
   1.163 +    movl   $0,%ebx		/ carry = 0
   1.164 +    mov    12(%ebp),%ecx	/ ecx = a_len
   1.165 +    mov    20(%ebp),%edi
   1.166 +    cmp    $0,%ecx
   1.167 +    je     L6			/ jmp if a_len == 0
   1.168 +    cld
   1.169 +    mov    8(%ebp),%esi		/ esi = a
   1.170 +L5:
   1.171 +    lodsl			/ eax = [ds:esi]; esi += 4
   1.172 +    mov    16(%ebp),%edx	/ edx = b
   1.173 +    mull   %edx			/ edx:eax = Phi:Plo = a_i * b
   1.174 +
   1.175 +    add    %ebx,%eax		/ add carry (%ebx) to edx:eax
   1.176 +    adc    $0,%edx
   1.177 +    mov    0(%edi),%ebx		/ add in current word from *c
   1.178 +    add    %ebx,%eax		
   1.179 +    adc    $0,%edx
   1.180 +    mov    %edx,%ebx		/ high half of product becomes next carry
   1.181 +
   1.182 +    stosl			/ [es:edi] = ax; edi += 4;
   1.183 +    dec    %ecx			/ --a_len
   1.184 +    jnz    L5			/ jmp if a_len != 0
   1.185 +L6:
   1.186 +    cmp    $0,%ebx		/ is carry zero?
   1.187 +    jz     L8
   1.188 +    mov    0(%edi),%eax		/ add in current word from *c
   1.189 +    add	   %ebx,%eax
   1.190 +    stosl			/ [es:edi] = ax; edi += 4;
   1.191 +    jnc    L8
   1.192 +L7:
   1.193 +    mov    0(%edi),%eax		/ add in current word from *c
   1.194 +    adc	   $0,%eax
   1.195 +    stosl			/ [es:edi] = ax; edi += 4;
   1.196 +    jc     L7
   1.197 +L8:
   1.198 +    pop    %ebx
   1.199 +    pop    %esi
   1.200 +    pop    %edi
   1.201 +    leave  
   1.202 +    ret    
   1.203 +    nop
   1.204 +
   1.205 + /  ebp - 20:	caller's esi
   1.206 + /  ebp - 16:	caller's edi
   1.207 + /  ebp - 12:	
   1.208 + /  ebp - 8:	carry
   1.209 + /  ebp - 4:	a_len	local
   1.210 + /  ebp + 0:	caller's ebp
   1.211 + /  ebp + 4:	return address
   1.212 + /  ebp + 8:	pa	argument
   1.213 + /  ebp + 12:	a_len	argument
   1.214 + /  ebp + 16:	ps	argument
   1.215 + /  ebp + 20:	
   1.216 + /  registers:
   1.217 + / 	eax:
   1.218 + /	ebx:	carry
   1.219 + /	ecx:	a_len
   1.220 + /	edx:
   1.221 + /	esi:	a ptr
   1.222 + /	edi:	c ptr
   1.223 +
   1.224 +.globl	s_mpv_sqr_add_prop
   1.225 +.type	s_mpv_sqr_add_prop,@function
   1.226 +s_mpv_sqr_add_prop:
   1.227 +     push   %ebp
   1.228 +     mov    %esp,%ebp
   1.229 +     sub    $12,%esp
   1.230 +     push   %edi
   1.231 +     push   %esi
   1.232 +     push   %ebx
   1.233 +     movl   $0,%ebx		/ carry = 0
   1.234 +     mov    12(%ebp),%ecx	/ a_len
   1.235 +     mov    16(%ebp),%edi	/ edi = ps
   1.236 +     cmp    $0,%ecx
   1.237 +     je     L11			/ jump if a_len == 0
   1.238 +     cld
   1.239 +     mov    8(%ebp),%esi	/ esi = pa
   1.240 +L10:
   1.241 +     lodsl			/ %eax = [ds:si]; si += 4;
   1.242 +     mull   %eax
   1.243 +
   1.244 +     add    %ebx,%eax		/ add "carry"
   1.245 +     adc    $0,%edx
   1.246 +     mov    0(%edi),%ebx
   1.247 +     add    %ebx,%eax		/ add low word from result
   1.248 +     mov    4(%edi),%ebx
   1.249 +     stosl			/ [es:di] = %eax; di += 4;
   1.250 +     adc    %ebx,%edx		/ add high word from result
   1.251 +     movl   $0,%ebx
   1.252 +     mov    %edx,%eax
   1.253 +     adc    $0,%ebx
   1.254 +     stosl			/ [es:di] = %eax; di += 4;
   1.255 +     dec    %ecx		/ --a_len
   1.256 +     jnz    L10			/ jmp if a_len != 0
   1.257 +L11:
   1.258 +    cmp    $0,%ebx		/ is carry zero?
   1.259 +    jz     L14
   1.260 +    mov    0(%edi),%eax		/ add in current word from *c
   1.261 +    add	   %ebx,%eax
   1.262 +    stosl			/ [es:edi] = ax; edi += 4;
   1.263 +    jnc    L14
   1.264 +L12:
   1.265 +    mov    0(%edi),%eax		/ add in current word from *c
   1.266 +    adc	   $0,%eax
   1.267 +    stosl			/ [es:edi] = ax; edi += 4;
   1.268 +    jc     L12
   1.269 +L14:
   1.270 +    pop    %ebx
   1.271 +    pop    %esi
   1.272 +    pop    %edi
   1.273 +    leave  
   1.274 +    ret    
   1.275 +    nop
   1.276 +
   1.277 + /
   1.278 + / Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
   1.279 + / so its high bit is 1.   This code is from NSPR.
   1.280 + /
   1.281 + / mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
   1.282 + / 		          mp_digit *qp, mp_digit *rp)
   1.283 +
   1.284 + /  esp +  0:   Caller's ebx
   1.285 + /  esp +  4:	return address
   1.286 + /  esp +  8:	Nhi	argument
   1.287 + /  esp + 12:	Nlo	argument
   1.288 + /  esp + 16:	divisor	argument
   1.289 + /  esp + 20:	qp	argument
   1.290 + /  esp + 24:   rp	argument
   1.291 + /  registers:
   1.292 + / 	eax:
   1.293 + /	ebx:	carry
   1.294 + /	ecx:	a_len
   1.295 + /	edx:
   1.296 + /	esi:	a ptr
   1.297 + /	edi:	c ptr
   1.298 + / 
   1.299 +
   1.300 +.globl	s_mpv_div_2dx1d
   1.301 +.type	s_mpv_div_2dx1d,@function
   1.302 +s_mpv_div_2dx1d:
   1.303 +       push   %ebx
   1.304 +       mov    8(%esp),%edx
   1.305 +       mov    12(%esp),%eax
   1.306 +       mov    16(%esp),%ebx
   1.307 +       div    %ebx
   1.308 +       mov    20(%esp),%ebx
   1.309 +       mov    %eax,0(%ebx)
   1.310 +       mov    24(%esp),%ebx
   1.311 +       mov    %edx,0(%ebx)
   1.312 +       xor    %eax,%eax		/ return zero
   1.313 +       pop    %ebx
   1.314 +       ret    
   1.315 +       nop
   1.316 +  

mercurial