| 1 | extrn _dllentry:dword
|
|---|
| 2 | title large_int.c
|
|---|
| 3 | .386
|
|---|
| 4 | .387
|
|---|
| 5 | CODE32 segment para use32 public 'CODE'
|
|---|
| 6 | CODE32 ends
|
|---|
| 7 | DATA32 segment para use32 public 'DATA'
|
|---|
| 8 | DATA32 ends
|
|---|
| 9 | CONST32_RO segment para use32 public 'CONST'
|
|---|
| 10 | CONST32_RO ends
|
|---|
| 11 | BSS32 segment para use32 public 'BSS'
|
|---|
| 12 | BSS32 ends
|
|---|
| 13 | DGROUP group BSS32, DATA32
|
|---|
| 14 | assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
|
|---|
| 15 | CODE32 segment
|
|---|
| 16 | extrn __modu64:proc
|
|---|
| 17 |
|
|---|
| 18 | ; 224 ULONGLONG WINAPI _aullrem( ULONGLONG a, ULONGLONG b )
|
|---|
| 19 | align 4
|
|---|
| 20 |
|
|---|
| 21 | public __aullrem@16
|
|---|
| 22 | __aullrem@16 proc
|
|---|
| 23 |
|
|---|
| 24 | ; 226 return a % b;
|
|---|
| 25 | mov ecx,[esp+010h]; b
|
|---|
| 26 | push ecx
|
|---|
| 27 | mov eax,[esp+08h]; a
|
|---|
| 28 | mov edx,[esp+0ch]; a
|
|---|
| 29 | mov ecx,[esp+010h]; b
|
|---|
| 30 | call __modu64
|
|---|
| 31 | pop ecx
|
|---|
| 32 | ret 010h
|
|---|
| 33 | __aullrem@16 endp
|
|---|
| 34 | extrn __divu64:proc
|
|---|
| 35 |
|
|---|
| 36 | ; 215 ULONGLONG WINAPI _aulldiv( ULONGLONG a, ULONGLONG b )
|
|---|
| 37 | align 4h
|
|---|
| 38 |
|
|---|
| 39 | public __aulldiv@16
|
|---|
| 40 | __aulldiv@16 proc
|
|---|
| 41 |
|
|---|
| 42 | ; 217 return a / b;
|
|---|
| 43 | mov ecx,[esp+010h]; b
|
|---|
| 44 | push ecx
|
|---|
| 45 | mov ecx,[esp+010h]; b
|
|---|
| 46 | mov edx,[esp+0ch]; a
|
|---|
| 47 | mov eax,[esp+08h]; a
|
|---|
| 48 | call __divu64
|
|---|
| 49 | pop ecx
|
|---|
| 50 | ret 010h
|
|---|
| 51 | __aulldiv@16 endp
|
|---|
| 52 | extrn __modi64:proc
|
|---|
| 53 |
|
|---|
| 54 | ; 206 LONGLONG WINAPI _allrem( LONGLONG a, LONGLONG b )
|
|---|
| 55 | align 4h
|
|---|
| 56 |
|
|---|
| 57 | public __allrem@16
|
|---|
| 58 | __allrem@16 proc
|
|---|
| 59 |
|
|---|
| 60 | ; 208 return a % b;
|
|---|
| 61 | mov ecx,[esp+010h]; b
|
|---|
| 62 | push ecx
|
|---|
| 63 | mov eax,[esp+08h]; a
|
|---|
| 64 | mov edx,[esp+0ch]; a
|
|---|
| 65 | mov ecx,[esp+010h]; b
|
|---|
| 66 | call __modi64
|
|---|
| 67 | pop ecx
|
|---|
| 68 | ret 010h
|
|---|
| 69 | __allrem@16 endp
|
|---|
| 70 | extrn __multi64:proc
|
|---|
| 71 |
|
|---|
| 72 | ; 197 LONGLONG WINAPI _allmul( LONGLONG a, LONGLONG b )
|
|---|
| 73 | align 4h
|
|---|
| 74 |
|
|---|
| 75 | public __allmul@16
|
|---|
| 76 | __allmul@16 proc
|
|---|
| 77 |
|
|---|
| 78 | ; 199 return a * b;
|
|---|
| 79 | mov ecx,[esp+010h]; b
|
|---|
| 80 | push ecx
|
|---|
| 81 | mov ecx,[esp+010h]; b
|
|---|
| 82 | mov edx,[esp+0ch]; a
|
|---|
| 83 | mov eax,[esp+08h]; a
|
|---|
| 84 | call __multi64
|
|---|
| 85 | pop ecx
|
|---|
| 86 | ret 010h
|
|---|
| 87 | __allmul@16 endp
|
|---|
| 88 | extrn __divi64:proc
|
|---|
| 89 |
|
|---|
| 90 | ; 188 LONGLONG WINAPI _alldiv( LONGLONG a, LONGLONG b )
|
|---|
| 91 | align 4h
|
|---|
| 92 |
|
|---|
| 93 | public __alldiv@16
|
|---|
| 94 | __alldiv@16 proc
|
|---|
| 95 |
|
|---|
| 96 | ; 190 return a / b;
|
|---|
| 97 | mov ecx,[esp+010h]; b
|
|---|
| 98 | push ecx
|
|---|
| 99 | sub esp,0ch
|
|---|
| 100 | mov ecx,[esp+01ch]; b
|
|---|
| 101 | mov edx,[esp+018h]; a
|
|---|
| 102 | mov eax,[esp+014h]; a
|
|---|
| 103 | call __divi64
|
|---|
| 104 | add esp,010h
|
|---|
| 105 | ret 010h
|
|---|
| 106 | __alldiv@16 endp
|
|---|
| 107 |
|
|---|
| 108 | ; 158 LONGLONG WINAPI RtlExtendedIntegerMultiply( LONGLONG a, INT b )
|
|---|
| 109 | align 4h
|
|---|
| 110 |
|
|---|
| 111 | public _RtlExtendedIntegerMultiply@12
|
|---|
| 112 | _RtlExtendedIntegerMultiply@12 proc
|
|---|
| 113 |
|
|---|
| 114 | ; 160 return a * b;
|
|---|
| 115 | mov ecx,[esp+08h]; a
|
|---|
| 116 | push ecx
|
|---|
| 117 | mov eax,[esp+010h]; b
|
|---|
| 118 | mov ecx,[esp+08h]; a
|
|---|
| 119 | mov edx,eax
|
|---|
| 120 | sar edx,01fh
|
|---|
| 121 | call __multi64
|
|---|
| 122 | pop ecx
|
|---|
| 123 | ret 0ch
|
|---|
| 124 | _RtlExtendedIntegerMultiply@12 endp
|
|---|
| 125 |
|
|---|
| 126 | ; 147 LONGLONG WINAPI RtlExtendedLargeIntegerDivide( LONGLONG a, INT b, INT *rem )
|
|---|
| 127 | align 4h
|
|---|
| 128 |
|
|---|
| 129 | public _RtlExtendedLargeIntegerDivide@16
|
|---|
| 130 | _RtlExtendedLargeIntegerDivide@16 proc
|
|---|
| 131 | sub esp,08h
|
|---|
| 132 | push ebx
|
|---|
| 133 | push edi
|
|---|
| 134 |
|
|---|
| 135 | ; 149 LONGLONG ret = a / b;
|
|---|
| 136 | mov ebx,[esp+01ch]; b
|
|---|
| 137 | mov ecx,ebx
|
|---|
| 138 | sar ecx,01fh
|
|---|
| 139 | push ecx
|
|---|
| 140 | mov ecx,ebx
|
|---|
| 141 | sub esp,0ch
|
|---|
| 142 | mov edi,[esp+024h]; a
|
|---|
| 143 | mov edx,[esp+028h]; a
|
|---|
| 144 | mov eax,edi
|
|---|
| 145 | call __divi64
|
|---|
| 146 | add esp,010h
|
|---|
| 147 |
|
|---|
| 148 | ; 150 if (rem) *rem = a - b * ret;
|
|---|
| 149 | mov ecx,[esp+020h]; rem
|
|---|
| 150 |
|
|---|
| 151 | ; 149 LONGLONG ret = a / b;
|
|---|
| 152 | mov [esp+08h],eax; ret
|
|---|
| 153 | mov [esp+0ch],edx; ret
|
|---|
| 154 |
|
|---|
| 155 | ; 150 if (rem) *rem = a - b * ret;
|
|---|
| 156 | test ecx,ecx
|
|---|
| 157 | je @BLBL15
|
|---|
| 158 | imul ebx,eax
|
|---|
| 159 | sub edi,ebx
|
|---|
| 160 | mov [ecx],edi
|
|---|
| 161 | @BLBL15:
|
|---|
| 162 |
|
|---|
| 163 | ; 151 return ret;
|
|---|
| 164 | pop edi
|
|---|
| 165 | pop ebx
|
|---|
| 166 | add esp,08h
|
|---|
| 167 | ret 010h
|
|---|
| 168 | _RtlExtendedLargeIntegerDivide@16 endp
|
|---|
| 169 |
|
|---|
| 170 | ; 127 UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
|
|---|
| 171 | align 4h
|
|---|
| 172 |
|
|---|
| 173 | public _RtlEnlargedUnsignedDivide@16
|
|---|
| 174 | _RtlEnlargedUnsignedDivide@16 proc
|
|---|
| 175 | push ebp
|
|---|
| 176 | push ebx
|
|---|
| 177 |
|
|---|
| 178 | ; 137 UINT ret = a / b;
|
|---|
| 179 | xor ebx,ebx
|
|---|
| 180 |
|
|---|
| 181 | ; 127 UINT WINAPI RtlEnlargedUnsignedDivide( ULONGLONG a, UINT b, UINT *remptr )
|
|---|
| 182 | push edi
|
|---|
| 183 | push esi
|
|---|
| 184 | push ebp
|
|---|
| 185 |
|
|---|
| 186 | ; 137 UINT ret = a / b;
|
|---|
| 187 | mov esi,[esp+020h]; b
|
|---|
| 188 | push ebx
|
|---|
| 189 | mov ebp,[esp+020h]; a
|
|---|
| 190 | mov edi,[esp+01ch]; a
|
|---|
| 191 | mov ecx,esi
|
|---|
| 192 | mov edx,ebp
|
|---|
| 193 | mov eax,edi
|
|---|
| 194 | call __divu64
|
|---|
| 195 | xchg edi,eax
|
|---|
| 196 | mov ecx,esi
|
|---|
| 197 | mov edx,ebp
|
|---|
| 198 | pop esi
|
|---|
| 199 | mov [esp],edi; ret
|
|---|
| 200 |
|
|---|
| 201 | ; 138 if (remptr) *remptr = a % b;
|
|---|
| 202 | mov edi,[esp+024h]; remptr
|
|---|
| 203 | test edi,edi
|
|---|
| 204 | je @BLBL13
|
|---|
| 205 | push ebx
|
|---|
| 206 | call __modu64
|
|---|
| 207 | mov [edi],eax
|
|---|
| 208 | pop ecx
|
|---|
| 209 | @BLBL13:
|
|---|
| 210 |
|
|---|
| 211 | ; 139 return ret;
|
|---|
| 212 | mov eax,[esp]; ret
|
|---|
| 213 | pop ecx
|
|---|
| 214 | pop esi
|
|---|
| 215 | pop edi
|
|---|
| 216 | pop ebx
|
|---|
| 217 | pop ebp
|
|---|
| 218 | ret 010h
|
|---|
| 219 | _RtlEnlargedUnsignedDivide@16 endp
|
|---|
| 220 |
|
|---|
| 221 | ; 118 ULONGLONG WINAPI RtlEnlargedUnsignedMultiply( UINT a, UINT b )
|
|---|
| 222 | align 4h
|
|---|
| 223 |
|
|---|
| 224 | public _RtlEnlargedUnsignedMultiply@8
|
|---|
| 225 | _RtlEnlargedUnsignedMultiply@8 proc
|
|---|
| 226 |
|
|---|
| 227 | ; 120 return (ULONGLONG)a * b;
|
|---|
| 228 | mov ecx,[esp+04h]; a
|
|---|
| 229 | xor eax,eax
|
|---|
| 230 | push eax
|
|---|
| 231 | xor edx,edx
|
|---|
| 232 | mov eax,[esp+0ch]; b
|
|---|
| 233 | call __multi64
|
|---|
| 234 | pop ecx
|
|---|
| 235 | ret 08h
|
|---|
| 236 | _RtlEnlargedUnsignedMultiply@8 endp
|
|---|
| 237 |
|
|---|
| 238 | ; 109 LONGLONG WINAPI RtlEnlargedIntegerMultiply( INT a, INT b )
|
|---|
| 239 | align 4h
|
|---|
| 240 |
|
|---|
| 241 | public _RtlEnlargedIntegerMultiply@8
|
|---|
| 242 | _RtlEnlargedIntegerMultiply@8 proc
|
|---|
| 243 |
|
|---|
| 244 | ; 111 return (LONGLONG)a * b;
|
|---|
| 245 | mov ecx,[esp+04h]; a
|
|---|
| 246 | mov eax,ecx
|
|---|
| 247 | sar eax,01fh
|
|---|
| 248 | push eax
|
|---|
| 249 | mov eax,[esp+0ch]; b
|
|---|
| 250 | mov edx,eax
|
|---|
| 251 | sar edx,01fh
|
|---|
| 252 | call __multi64
|
|---|
| 253 | pop ecx
|
|---|
| 254 | ret 08h
|
|---|
| 255 | _RtlEnlargedIntegerMultiply@8 endp
|
|---|
| 256 |
|
|---|
| 257 | ; 100 ULONGLONG WINAPI RtlConvertUlongToLargeInteger( ULONG a )
|
|---|
| 258 | align 4h
|
|---|
| 259 |
|
|---|
| 260 | public _RtlConvertUlongToLargeInteger@4
|
|---|
| 261 | _RtlConvertUlongToLargeInteger@4 proc
|
|---|
| 262 |
|
|---|
| 263 | ; 102 return a;
|
|---|
| 264 | mov eax,[esp+04h]; a
|
|---|
| 265 | xor edx,edx
|
|---|
| 266 | ret 04h
|
|---|
| 267 | _RtlConvertUlongToLargeInteger@4 endp
|
|---|
| 268 |
|
|---|
| 269 | ; 91 LONGLONG WINAPI RtlConvertLongToLargeInteger( LONG a )
|
|---|
| 270 | align 4h
|
|---|
| 271 |
|
|---|
| 272 | public _RtlConvertLongToLargeInteger@4
|
|---|
| 273 | _RtlConvertLongToLargeInteger@4 proc
|
|---|
| 274 |
|
|---|
| 275 | ; 93 return a;
|
|---|
| 276 | mov eax,[esp+04h]; a
|
|---|
| 277 | mov edx,eax
|
|---|
| 278 | sar edx,01fh
|
|---|
| 279 | ret 04h
|
|---|
| 280 | _RtlConvertLongToLargeInteger@4 endp
|
|---|
| 281 |
|
|---|
| 282 | ; 80 ULONGLONG WINAPI RtlLargeIntegerDivide( ULONGLONG a, ULONGLONG b, ULONGLONG *rem )
|
|---|
| 283 | align 4h
|
|---|
| 284 |
|
|---|
| 285 | public _RtlLargeIntegerDivide@20
|
|---|
| 286 | _RtlLargeIntegerDivide@20 proc
|
|---|
| 287 | push ebp
|
|---|
| 288 | push ebx
|
|---|
| 289 | push edi
|
|---|
| 290 | push esi
|
|---|
| 291 | sub esp,08h
|
|---|
| 292 |
|
|---|
| 293 | ; 82 ULONGLONG ret = a / b;
|
|---|
| 294 | mov ebp,[esp+028h]; b
|
|---|
| 295 | push ebp
|
|---|
| 296 | mov ebx,[esp+028h]; b
|
|---|
| 297 | mov esi,[esp+024h]; a
|
|---|
| 298 | mov edi,[esp+020h]; a
|
|---|
| 299 | mov ecx,ebx
|
|---|
| 300 | mov edx,esi
|
|---|
| 301 | mov eax,edi
|
|---|
| 302 | call __divu64
|
|---|
| 303 | mov ecx,ebx
|
|---|
| 304 | pop ebx
|
|---|
| 305 |
|
|---|
| 306 | ; 83 if (rem) *rem = a - ret * b;
|
|---|
| 307 | mov ebx,[esp+02ch]; rem
|
|---|
| 308 |
|
|---|
| 309 | ; 82 ULONGLONG ret = a / b;
|
|---|
| 310 | mov [esp],eax; ret
|
|---|
| 311 | mov [esp+04h],edx; ret
|
|---|
| 312 |
|
|---|
| 313 | ; 83 if (rem) *rem = a - ret * b;
|
|---|
| 314 | test ebx,ebx
|
|---|
| 315 | je @BLBL7
|
|---|
| 316 | push ebp
|
|---|
| 317 | call __multi64
|
|---|
| 318 | mov ecx,edi
|
|---|
| 319 | pop edi
|
|---|
| 320 | sub ecx,eax
|
|---|
| 321 | sbb esi,edx
|
|---|
| 322 | mov [ebx],ecx
|
|---|
| 323 | mov [ebx+04h],esi
|
|---|
| 324 | @BLBL7:
|
|---|
| 325 |
|
|---|
| 326 | ; 84 return ret;
|
|---|
| 327 | mov eax,[esp]; ret
|
|---|
| 328 | mov edx,[esp+04h]; ret
|
|---|
| 329 | add esp,08h
|
|---|
| 330 | pop esi
|
|---|
| 331 | pop edi
|
|---|
| 332 | pop ebx
|
|---|
| 333 | pop ebp
|
|---|
| 334 | ret 014h
|
|---|
| 335 | _RtlLargeIntegerDivide@20 endp
|
|---|
| 336 |
|
|---|
| 337 | ; 68 LONGLONG WINAPI RtlLargeIntegerArithmeticShift( LONGLONG a, INT count )
|
|---|
| 338 | align 4h
|
|---|
| 339 |
|
|---|
| 340 | public _RtlLargeIntegerArithmeticShift@12
|
|---|
| 341 | _RtlLargeIntegerArithmeticShift@12 proc
|
|---|
| 342 |
|
|---|
| 343 | ; 71 return a >> count;
|
|---|
| 344 | mov ecx,[esp+0ch]; count
|
|---|
| 345 | mov edx,[esp+08h]; a
|
|---|
| 346 | and ecx,03fh
|
|---|
| 347 | mov eax,[esp+04h]; a
|
|---|
| 348 | cmp ecx,01fh
|
|---|
| 349 | jg @BLBL23
|
|---|
| 350 | shrd eax,edx,cl
|
|---|
| 351 | sar edx,cl
|
|---|
| 352 | jmp @BLBL24
|
|---|
| 353 | @BLBL23:
|
|---|
| 354 | mov eax,edx
|
|---|
| 355 | sub cl,020h
|
|---|
| 356 | sar edx,01fh
|
|---|
| 357 | sar eax,cl
|
|---|
| 358 | @BLBL24:
|
|---|
| 359 | ret 0ch
|
|---|
| 360 | _RtlLargeIntegerArithmeticShift@12 endp
|
|---|
| 361 |
|
|---|
| 362 | ; 59 LONGLONG WINAPI RtlLargeIntegerShiftRight( LONGLONG a, INT count )
|
|---|
| 363 | align 4h
|
|---|
| 364 |
|
|---|
| 365 | public _RtlLargeIntegerShiftRight@12
|
|---|
| 366 | _RtlLargeIntegerShiftRight@12 proc
|
|---|
| 367 |
|
|---|
| 368 | ; 61 return (ULONGLONG)a >> count;
|
|---|
| 369 | mov ecx,[esp+0ch]; count
|
|---|
| 370 | mov eax,[esp+04h]; a
|
|---|
| 371 | and ecx,03fh
|
|---|
| 372 | mov edx,[esp+08h]; a
|
|---|
| 373 | cmp ecx,01fh
|
|---|
| 374 | jg @BLBL25
|
|---|
| 375 | shrd eax,edx,cl
|
|---|
| 376 | shr edx,cl
|
|---|
| 377 | jmp @BLBL26
|
|---|
| 378 | @BLBL25:
|
|---|
| 379 | mov eax,edx
|
|---|
| 380 | sub cl,020h
|
|---|
| 381 | shr eax,cl
|
|---|
| 382 | xor edx,edx
|
|---|
| 383 | @BLBL26:
|
|---|
| 384 | ret 0ch
|
|---|
| 385 | _RtlLargeIntegerShiftRight@12 endp
|
|---|
| 386 |
|
|---|
| 387 | ; 50 LONGLONG WINAPI RtlLargeIntegerShiftLeft( LONGLONG a, INT count )
|
|---|
| 388 | align 4h
|
|---|
| 389 |
|
|---|
| 390 | public _RtlLargeIntegerShiftLeft@12
|
|---|
| 391 | _RtlLargeIntegerShiftLeft@12 proc
|
|---|
| 392 |
|
|---|
| 393 | ; 52 return a << count;
|
|---|
| 394 | mov ecx,[esp+0ch]; count
|
|---|
| 395 | mov eax,[esp+04h]; a
|
|---|
| 396 | and ecx,03fh
|
|---|
| 397 | mov edx,[esp+08h]; a
|
|---|
| 398 | cmp ecx,01fh
|
|---|
| 399 | jg @BLBL27
|
|---|
| 400 | shld edx,eax,cl
|
|---|
| 401 | shl eax,cl
|
|---|
| 402 | jmp @BLBL28
|
|---|
| 403 | @BLBL27:
|
|---|
| 404 | mov edx,eax
|
|---|
| 405 | sub cl,020h
|
|---|
| 406 | shl edx,cl
|
|---|
| 407 | xor eax,eax
|
|---|
| 408 | @BLBL28:
|
|---|
| 409 | ret 0ch
|
|---|
| 410 | _RtlLargeIntegerShiftLeft@12 endp
|
|---|
| 411 |
|
|---|
| 412 | ; 41 LONGLONG WINAPI RtlLargeIntegerNegate( LONGLONG a )
|
|---|
| 413 | align 4h
|
|---|
| 414 |
|
|---|
| 415 | public _RtlLargeIntegerNegate@8
|
|---|
| 416 | _RtlLargeIntegerNegate@8 proc
|
|---|
| 417 |
|
|---|
| 418 | ; 43 return -a;
|
|---|
| 419 | mov eax,[esp+04h]; a
|
|---|
| 420 | mov edx,[esp+08h]; a
|
|---|
| 421 | not eax
|
|---|
| 422 | not edx
|
|---|
| 423 | add eax,01h
|
|---|
| 424 | adc edx,0h
|
|---|
| 425 | ret 08h
|
|---|
| 426 | _RtlLargeIntegerNegate@8 endp
|
|---|
| 427 |
|
|---|
| 428 | ; 32 LONGLONG WINAPI RtlLargeIntegerSubtract( LONGLONG a, LONGLONG b )
|
|---|
| 429 | align 4h
|
|---|
| 430 |
|
|---|
| 431 | public _RtlLargeIntegerSubtract@16
|
|---|
| 432 | _RtlLargeIntegerSubtract@16 proc
|
|---|
| 433 |
|
|---|
| 434 | ; 34 return a - b;
|
|---|
| 435 | mov eax,[esp+04h]; a
|
|---|
| 436 | mov edx,[esp+08h]; a
|
|---|
| 437 | sub eax,[esp+0ch]; b
|
|---|
| 438 | sbb edx,[esp+010h]; b
|
|---|
| 439 | ret 010h
|
|---|
| 440 | _RtlLargeIntegerSubtract@16 endp
|
|---|
| 441 |
|
|---|
| 442 | ; 23 LONGLONG WINAPI RtlLargeIntegerAdd( LONGLONG a, LONGLONG b )
|
|---|
| 443 | align 4h
|
|---|
| 444 |
|
|---|
| 445 | public _RtlLargeIntegerAdd@16
|
|---|
| 446 | _RtlLargeIntegerAdd@16 proc
|
|---|
| 447 |
|
|---|
| 448 | ; 25 return a + b;
|
|---|
| 449 | mov eax,[esp+04h]; a
|
|---|
| 450 | mov edx,[esp+08h]; a
|
|---|
| 451 | add eax,[esp+0ch]; b
|
|---|
| 452 | adc edx,[esp+010h]; b
|
|---|
| 453 | ret 010h
|
|---|
| 454 | _RtlLargeIntegerAdd@16 endp
|
|---|
| 455 | CODE32 ends
|
|---|
| 456 | end
|
|---|