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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /
michael@0 2 / This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 / License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 / file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6 .text
michael@0 7
michael@0 8 / ebp - 36: caller's esi
michael@0 9 / ebp - 32: caller's edi
michael@0 10 / ebp - 28:
michael@0 11 / ebp - 24:
michael@0 12 / ebp - 20:
michael@0 13 / ebp - 16:
michael@0 14 / ebp - 12:
michael@0 15 / ebp - 8:
michael@0 16 / ebp - 4:
michael@0 17 / ebp + 0: caller's ebp
michael@0 18 / ebp + 4: return address
michael@0 19 / ebp + 8: a argument
michael@0 20 / ebp + 12: a_len argument
michael@0 21 / ebp + 16: b argument
michael@0 22 / ebp + 20: c argument
michael@0 23 / registers:
michael@0 24 / eax:
michael@0 25 / ebx: carry
michael@0 26 / ecx: a_len
michael@0 27 / edx:
michael@0 28 / esi: a ptr
michael@0 29 / edi: c ptr
michael@0 30 .globl s_mpv_mul_d
michael@0 31 .type s_mpv_mul_d,@function
michael@0 32 s_mpv_mul_d:
michael@0 33 push %ebp
michael@0 34 mov %esp,%ebp
michael@0 35 sub $28,%esp
michael@0 36 push %edi
michael@0 37 push %esi
michael@0 38 push %ebx
michael@0 39 movl $0,%ebx / carry = 0
michael@0 40 mov 12(%ebp),%ecx / ecx = a_len
michael@0 41 mov 20(%ebp),%edi
michael@0 42 cmp $0,%ecx
michael@0 43 je L2 / jmp if a_len == 0
michael@0 44 mov 8(%ebp),%esi / esi = a
michael@0 45 cld
michael@0 46 L1:
michael@0 47 lodsl / eax = [ds:esi]; esi += 4
michael@0 48 mov 16(%ebp),%edx / edx = b
michael@0 49 mull %edx / edx:eax = Phi:Plo = a_i * b
michael@0 50
michael@0 51 add %ebx,%eax / add carry (%ebx) to edx:eax
michael@0 52 adc $0,%edx
michael@0 53 mov %edx,%ebx / high half of product becomes next carry
michael@0 54
michael@0 55 stosl / [es:edi] = ax; edi += 4;
michael@0 56 dec %ecx / --a_len
michael@0 57 jnz L1 / jmp if a_len != 0
michael@0 58 L2:
michael@0 59 mov %ebx,0(%edi) / *c = carry
michael@0 60 pop %ebx
michael@0 61 pop %esi
michael@0 62 pop %edi
michael@0 63 leave
michael@0 64 ret
michael@0 65 nop
michael@0 66
michael@0 67 / ebp - 36: caller's esi
michael@0 68 / ebp - 32: caller's edi
michael@0 69 / ebp - 28:
michael@0 70 / ebp - 24:
michael@0 71 / ebp - 20:
michael@0 72 / ebp - 16:
michael@0 73 / ebp - 12:
michael@0 74 / ebp - 8:
michael@0 75 / ebp - 4:
michael@0 76 / ebp + 0: caller's ebp
michael@0 77 / ebp + 4: return address
michael@0 78 / ebp + 8: a argument
michael@0 79 / ebp + 12: a_len argument
michael@0 80 / ebp + 16: b argument
michael@0 81 / ebp + 20: c argument
michael@0 82 / registers:
michael@0 83 / eax:
michael@0 84 / ebx: carry
michael@0 85 / ecx: a_len
michael@0 86 / edx:
michael@0 87 / esi: a ptr
michael@0 88 / edi: c ptr
michael@0 89 .globl s_mpv_mul_d_add
michael@0 90 .type s_mpv_mul_d_add,@function
michael@0 91 s_mpv_mul_d_add:
michael@0 92 push %ebp
michael@0 93 mov %esp,%ebp
michael@0 94 sub $28,%esp
michael@0 95 push %edi
michael@0 96 push %esi
michael@0 97 push %ebx
michael@0 98 movl $0,%ebx / carry = 0
michael@0 99 mov 12(%ebp),%ecx / ecx = a_len
michael@0 100 mov 20(%ebp),%edi
michael@0 101 cmp $0,%ecx
michael@0 102 je L4 / jmp if a_len == 0
michael@0 103 mov 8(%ebp),%esi / esi = a
michael@0 104 cld
michael@0 105 L3:
michael@0 106 lodsl / eax = [ds:esi]; esi += 4
michael@0 107 mov 16(%ebp),%edx / edx = b
michael@0 108 mull %edx / edx:eax = Phi:Plo = a_i * b
michael@0 109
michael@0 110 add %ebx,%eax / add carry (%ebx) to edx:eax
michael@0 111 adc $0,%edx
michael@0 112 mov 0(%edi),%ebx / add in current word from *c
michael@0 113 add %ebx,%eax
michael@0 114 adc $0,%edx
michael@0 115 mov %edx,%ebx / high half of product becomes next carry
michael@0 116
michael@0 117 stosl / [es:edi] = ax; edi += 4;
michael@0 118 dec %ecx / --a_len
michael@0 119 jnz L3 / jmp if a_len != 0
michael@0 120 L4:
michael@0 121 mov %ebx,0(%edi) / *c = carry
michael@0 122 pop %ebx
michael@0 123 pop %esi
michael@0 124 pop %edi
michael@0 125 leave
michael@0 126 ret
michael@0 127 nop
michael@0 128
michael@0 129 / ebp - 36: caller's esi
michael@0 130 / ebp - 32: caller's edi
michael@0 131 / ebp - 28:
michael@0 132 / ebp - 24:
michael@0 133 / ebp - 20:
michael@0 134 / ebp - 16:
michael@0 135 / ebp - 12:
michael@0 136 / ebp - 8:
michael@0 137 / ebp - 4:
michael@0 138 / ebp + 0: caller's ebp
michael@0 139 / ebp + 4: return address
michael@0 140 / ebp + 8: a argument
michael@0 141 / ebp + 12: a_len argument
michael@0 142 / ebp + 16: b argument
michael@0 143 / ebp + 20: c argument
michael@0 144 / registers:
michael@0 145 / eax:
michael@0 146 / ebx: carry
michael@0 147 / ecx: a_len
michael@0 148 / edx:
michael@0 149 / esi: a ptr
michael@0 150 / edi: c ptr
michael@0 151 .globl s_mpv_mul_d_add_prop
michael@0 152 .type s_mpv_mul_d_add_prop,@function
michael@0 153 s_mpv_mul_d_add_prop:
michael@0 154 push %ebp
michael@0 155 mov %esp,%ebp
michael@0 156 sub $28,%esp
michael@0 157 push %edi
michael@0 158 push %esi
michael@0 159 push %ebx
michael@0 160 movl $0,%ebx / carry = 0
michael@0 161 mov 12(%ebp),%ecx / ecx = a_len
michael@0 162 mov 20(%ebp),%edi
michael@0 163 cmp $0,%ecx
michael@0 164 je L6 / jmp if a_len == 0
michael@0 165 cld
michael@0 166 mov 8(%ebp),%esi / esi = a
michael@0 167 L5:
michael@0 168 lodsl / eax = [ds:esi]; esi += 4
michael@0 169 mov 16(%ebp),%edx / edx = b
michael@0 170 mull %edx / edx:eax = Phi:Plo = a_i * b
michael@0 171
michael@0 172 add %ebx,%eax / add carry (%ebx) to edx:eax
michael@0 173 adc $0,%edx
michael@0 174 mov 0(%edi),%ebx / add in current word from *c
michael@0 175 add %ebx,%eax
michael@0 176 adc $0,%edx
michael@0 177 mov %edx,%ebx / high half of product becomes next carry
michael@0 178
michael@0 179 stosl / [es:edi] = ax; edi += 4;
michael@0 180 dec %ecx / --a_len
michael@0 181 jnz L5 / jmp if a_len != 0
michael@0 182 L6:
michael@0 183 cmp $0,%ebx / is carry zero?
michael@0 184 jz L8
michael@0 185 mov 0(%edi),%eax / add in current word from *c
michael@0 186 add %ebx,%eax
michael@0 187 stosl / [es:edi] = ax; edi += 4;
michael@0 188 jnc L8
michael@0 189 L7:
michael@0 190 mov 0(%edi),%eax / add in current word from *c
michael@0 191 adc $0,%eax
michael@0 192 stosl / [es:edi] = ax; edi += 4;
michael@0 193 jc L7
michael@0 194 L8:
michael@0 195 pop %ebx
michael@0 196 pop %esi
michael@0 197 pop %edi
michael@0 198 leave
michael@0 199 ret
michael@0 200 nop
michael@0 201
michael@0 202 / ebp - 20: caller's esi
michael@0 203 / ebp - 16: caller's edi
michael@0 204 / ebp - 12:
michael@0 205 / ebp - 8: carry
michael@0 206 / ebp - 4: a_len local
michael@0 207 / ebp + 0: caller's ebp
michael@0 208 / ebp + 4: return address
michael@0 209 / ebp + 8: pa argument
michael@0 210 / ebp + 12: a_len argument
michael@0 211 / ebp + 16: ps argument
michael@0 212 / ebp + 20:
michael@0 213 / registers:
michael@0 214 / eax:
michael@0 215 / ebx: carry
michael@0 216 / ecx: a_len
michael@0 217 / edx:
michael@0 218 / esi: a ptr
michael@0 219 / edi: c ptr
michael@0 220
michael@0 221 .globl s_mpv_sqr_add_prop
michael@0 222 .type s_mpv_sqr_add_prop,@function
michael@0 223 s_mpv_sqr_add_prop:
michael@0 224 push %ebp
michael@0 225 mov %esp,%ebp
michael@0 226 sub $12,%esp
michael@0 227 push %edi
michael@0 228 push %esi
michael@0 229 push %ebx
michael@0 230 movl $0,%ebx / carry = 0
michael@0 231 mov 12(%ebp),%ecx / a_len
michael@0 232 mov 16(%ebp),%edi / edi = ps
michael@0 233 cmp $0,%ecx
michael@0 234 je L11 / jump if a_len == 0
michael@0 235 cld
michael@0 236 mov 8(%ebp),%esi / esi = pa
michael@0 237 L10:
michael@0 238 lodsl / %eax = [ds:si]; si += 4;
michael@0 239 mull %eax
michael@0 240
michael@0 241 add %ebx,%eax / add "carry"
michael@0 242 adc $0,%edx
michael@0 243 mov 0(%edi),%ebx
michael@0 244 add %ebx,%eax / add low word from result
michael@0 245 mov 4(%edi),%ebx
michael@0 246 stosl / [es:di] = %eax; di += 4;
michael@0 247 adc %ebx,%edx / add high word from result
michael@0 248 movl $0,%ebx
michael@0 249 mov %edx,%eax
michael@0 250 adc $0,%ebx
michael@0 251 stosl / [es:di] = %eax; di += 4;
michael@0 252 dec %ecx / --a_len
michael@0 253 jnz L10 / jmp if a_len != 0
michael@0 254 L11:
michael@0 255 cmp $0,%ebx / is carry zero?
michael@0 256 jz L14
michael@0 257 mov 0(%edi),%eax / add in current word from *c
michael@0 258 add %ebx,%eax
michael@0 259 stosl / [es:edi] = ax; edi += 4;
michael@0 260 jnc L14
michael@0 261 L12:
michael@0 262 mov 0(%edi),%eax / add in current word from *c
michael@0 263 adc $0,%eax
michael@0 264 stosl / [es:edi] = ax; edi += 4;
michael@0 265 jc L12
michael@0 266 L14:
michael@0 267 pop %ebx
michael@0 268 pop %esi
michael@0 269 pop %edi
michael@0 270 leave
michael@0 271 ret
michael@0 272 nop
michael@0 273
michael@0 274 /
michael@0 275 / Divide 64-bit (Nhi,Nlo) by 32-bit divisor, which must be normalized
michael@0 276 / so its high bit is 1. This code is from NSPR.
michael@0 277 /
michael@0 278 / mp_err s_mpv_div_2dx1d(mp_digit Nhi, mp_digit Nlo, mp_digit divisor,
michael@0 279 / mp_digit *qp, mp_digit *rp)
michael@0 280
michael@0 281 / esp + 0: Caller's ebx
michael@0 282 / esp + 4: return address
michael@0 283 / esp + 8: Nhi argument
michael@0 284 / esp + 12: Nlo argument
michael@0 285 / esp + 16: divisor argument
michael@0 286 / esp + 20: qp argument
michael@0 287 / esp + 24: rp argument
michael@0 288 / registers:
michael@0 289 / eax:
michael@0 290 / ebx: carry
michael@0 291 / ecx: a_len
michael@0 292 / edx:
michael@0 293 / esi: a ptr
michael@0 294 / edi: c ptr
michael@0 295 /
michael@0 296
michael@0 297 .globl s_mpv_div_2dx1d
michael@0 298 .type s_mpv_div_2dx1d,@function
michael@0 299 s_mpv_div_2dx1d:
michael@0 300 push %ebx
michael@0 301 mov 8(%esp),%edx
michael@0 302 mov 12(%esp),%eax
michael@0 303 mov 16(%esp),%ebx
michael@0 304 div %ebx
michael@0 305 mov 20(%esp),%ebx
michael@0 306 mov %eax,0(%ebx)
michael@0 307 mov 24(%esp),%ebx
michael@0 308 mov %edx,0(%ebx)
michael@0 309 xor %eax,%eax / return zero
michael@0 310 pop %ebx
michael@0 311 ret
michael@0 312 nop
michael@0 313

mercurial