Atlas - SDL_stdlib.c
Home / ext / SDL2 / src / stdlib Lines: 2 | Size: 25120 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2018 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21 22#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) 23#define SDL_DISABLE_ANALYZE_MACROS 1 24#endif 25 26#include "../SDL_internal.h" 27 28/* This file contains portable stdlib functions for SDL */ 29 30#include "SDL_stdinc.h" 31#include "../libm/math_libm.h" 32 33 34double 35SDL_atan(double x) 36{ 37#if defined(HAVE_ATAN) 38 return atan(x); 39#else 40 return SDL_uclibc_atan(x); 41#endif 42} 43 44float 45SDL_atanf(float x) 46{ 47#if defined(HAVE_ATANF) 48 return atanf(x); 49#else 50 return (float)SDL_atan((double)x); 51#endif 52} 53 54double 55SDL_atan2(double x, double y) 56{ 57#if defined(HAVE_ATAN2) 58 return atan2(x, y); 59#else 60 return SDL_uclibc_atan2(x, y); 61#endif 62} 63 64float 65SDL_atan2f(float x, float y) 66{ 67#if defined(HAVE_ATAN2F) 68 return atan2f(x, y); 69#else 70 return (float)SDL_atan2((double)x, (double)y); 71#endif 72} 73 74double 75SDL_acos(double val) 76{ 77#if defined(HAVE_ACOS) 78 return acos(val); 79#else 80 double result; 81 if (val == -1.0) { 82 result = M_PI; 83 } else { 84 result = SDL_atan(SDL_sqrt(1.0 - val * val) / val); 85 if (result < 0.0) 86 { 87 result += M_PI; 88 } 89 } 90 return result; 91#endif 92} 93 94float 95SDL_acosf(float val) 96{ 97#if defined(HAVE_ACOSF) 98 return acosf(val); 99#else 100 return (float)SDL_acos((double)val); 101#endif 102} 103 104double 105SDL_asin(double val) 106{ 107#if defined(HAVE_ASIN) 108 return asin(val); 109#else 110 double result; 111 if (val == -1.0) { 112 result = -(M_PI / 2.0); 113 } else { 114 result = (M_PI / 2.0) - SDL_acos(val); 115 } 116 return result; 117#endif 118} 119 120float 121SDL_asinf(float val) 122{ 123#if defined(HAVE_ASINF) 124 return asinf(val); 125#else 126 return (float)SDL_asin((double)val); 127#endif 128} 129 130double 131SDL_ceil(double x) 132{ 133#if defined(HAVE_CEIL) 134 return ceil(x); 135#else 136 double integer = SDL_floor(x); 137 double fraction = x - integer; 138 if (fraction > 0.0) { 139 integer += 1.0; 140 } 141 return integer; 142#endif /* HAVE_CEIL */ 143} 144 145float 146SDL_ceilf(float x) 147{ 148#if defined(HAVE_CEILF) 149 return ceilf(x); 150#else 151 return (float)SDL_ceil((float)x); 152#endif 153} 154 155double 156SDL_copysign(double x, double y) 157{ 158#if defined(HAVE_COPYSIGN) 159 return copysign(x, y); 160#elif defined(HAVE__COPYSIGN) 161 return _copysign(x, y); 162#elif defined(__WATCOMC__) && defined(__386__) 163 /* this is nasty as hell, but it works.. */ 164 unsigned int *xi = (unsigned int *) &x, 165 *yi = (unsigned int *) &y; 166 xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff); 167 return x; 168#else 169 return SDL_uclibc_copysign(x, y); 170#endif /* HAVE_COPYSIGN */ 171} 172 173float 174SDL_copysignf(float x, float y) 175{ 176#if defined(HAVE_COPYSIGNF) 177 return copysignf(x, y); 178#else 179 return (float)SDL_copysign((double)x, (double)y); 180#endif 181} 182 183double 184SDL_cos(double x) 185{ 186#if defined(HAVE_COS) 187 return cos(x); 188#else 189 return SDL_uclibc_cos(x); 190#endif 191} 192 193float 194SDL_cosf(float x) 195{ 196#if defined(HAVE_COSF) 197 return cosf(x); 198#else 199 return (float)SDL_cos((double)x); 200#endif 201} 202 203double 204SDL_exp(double x) 205{ 206#if defined(HAVE_EXP) 207 return exp(x); 208#else 209 return SDL_uclibc_exp(x); 210#endif 211} 212 213float 214SDL_expf(float x) 215{ 216#if defined(HAVE_EXPF) 217 return expf(x); 218#else 219 return (float)SDL_exp((double)x); 220#endif 221} 222 223double 224SDL_fabs(double x) 225{ 226#if defined(HAVE_FABS) 227 return fabs(x); 228#else 229 return SDL_uclibc_fabs(x); 230#endif 231} 232 233float 234SDL_fabsf(float x) 235{ 236#if defined(HAVE_FABSF) 237 return fabsf(x); 238#else 239 return (float)SDL_fabs((double)x); 240#endif 241} 242 243double 244SDL_floor(double x) 245{ 246#if defined(HAVE_FLOOR) 247 return floor(x); 248#else 249 return SDL_uclibc_floor(x); 250#endif 251} 252 253float 254SDL_floorf(float x) 255{ 256#if defined(HAVE_FLOORF) 257 return floorf(x); 258#else 259 return (float)SDL_floor((double)x); 260#endif 261} 262 263double 264SDL_fmod(double x, double y) 265{ 266#if defined(HAVE_FMOD) 267 return fmod(x, y); 268#else 269 return SDL_uclibc_fmod(x, y); 270#endif 271} 272 273float 274SDL_fmodf(float x, float y) 275{ 276#if defined(HAVE_FMODF) 277 return fmodf(x, y); 278#else 279 return (float)SDL_fmod((double)x, (double)y); 280#endif 281} 282 283double 284SDL_log(double x) 285{ 286#if defined(HAVE_LOG) 287 return log(x); 288#else 289 return SDL_uclibc_log(x); 290#endif 291} 292 293float 294SDL_logf(float x) 295{ 296#if defined(HAVE_LOGF) 297 return logf(x); 298#else 299 return (float)SDL_log((double)x); 300#endif 301} 302 303double 304SDL_log10(double x) 305{ 306#if defined(HAVE_LOG10) 307 return log10(x); 308#else 309 return SDL_uclibc_log10(x); 310#endif 311} 312 313float 314SDL_log10f(float x) 315{ 316#if defined(HAVE_LOG10F) 317 return log10f(x); 318#else 319 return (float)SDL_log10((double)x); 320#endif 321} 322 323double 324SDL_pow(double x, double y) 325{ 326#if defined(HAVE_POW) 327 return pow(x, y); 328#else 329 return SDL_uclibc_pow(x, y); 330#endif 331} 332 333float 334SDL_powf(float x, float y) 335{ 336#if defined(HAVE_POWF) 337 return powf(x, y); 338#else 339 return (float)SDL_pow((double)x, (double)y); 340#endif 341} 342 343double 344SDL_scalbn(double x, int n) 345{ 346#if defined(HAVE_SCALBN) 347 return scalbn(x, n); 348#elif defined(HAVE__SCALB) 349 return _scalb(x, n); 350#elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2) 351/* from scalbn(3): If FLT_RADIX equals 2 (which is 352 * usual), then scalbn() is equivalent to ldexp(3). */ 353 return ldexp(x, n); 354#else 355 return SDL_uclibc_scalbn(x, n); 356#endif 357} 358 359float 360SDL_scalbnf(float x, int n) 361{ 362#if defined(HAVE_SCALBNF) 363 return scalbnf(x, n); 364#else 365 return (float)SDL_scalbn((double)x, n); 366#endif 367} 368 369double 370SDL_sin(double x) 371{ 372#if defined(HAVE_SIN) 373 return sin(x); 374#else 375 return SDL_uclibc_sin(x); 376#endif 377} 378 379float 380SDL_sinf(float x) 381{ 382#if defined(HAVE_SINF) 383 return sinf(x); 384#else 385 return (float)SDL_sin((double)x); 386#endif 387} 388 389double 390SDL_sqrt(double x) 391{ 392#if defined(HAVE_SQRT) 393 return sqrt(x); 394#else 395 return SDL_uclibc_sqrt(x); 396#endif 397} 398 399float 400SDL_sqrtf(float x) 401{ 402#if defined(HAVE_SQRTF) 403 return sqrtf(x); 404#else 405 return (float)SDL_sqrt((double)x); 406#endif 407} 408 409double 410SDL_tan(double x) 411{ 412#if defined(HAVE_TAN) 413 return tan(x); 414#else 415 return SDL_uclibc_tan(x); 416#endif 417} 418 419float 420SDL_tanf(float x) 421{ 422#if defined(HAVE_TANF) 423 return tanf(x); 424#else 425 return (float)SDL_tan((double)x); 426#endif 427} 428 429int SDL_abs(int x) 430{ 431#if defined(HAVE_ABS) 432 return abs(x); 433#else 434 return ((x) < 0 ? -(x) : (x)); 435#endif 436} 437 438#if defined(HAVE_CTYPE_H) 439int SDL_isdigit(int x) { return isdigit(x); } 440int SDL_isspace(int x) { return isspace(x); } 441int SDL_toupper(int x) { return toupper(x); } 442int SDL_tolower(int x) { return tolower(x); } 443#else 444int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); } 445int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); } 446int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); } 447int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); } 448#endif 449 450 451#ifndef HAVE_LIBC 452/* These are some C runtime intrinsics that need to be defined */ 453 454#if defined(_MSC_VER) 455 456#ifndef __FLTUSED__ 457#define __FLTUSED__ 458__declspec(selectany) int _fltused = 1; 459#endif 460 461/* The optimizer on Visual Studio 2005 and later generates memcpy() calls */ 462#if (_MSC_VER >= 1400) && defined(_WIN64) && !defined(_DEBUG) && !(_MSC_VER >= 1900 && defined(_MT)) 463#include <intrin.h> 464 465#pragma function(memcpy) 466void * memcpy ( void * destination, const void * source, size_t num ) 467{ 468 const Uint8 *src = (const Uint8 *)source; 469 Uint8 *dst = (Uint8 *)destination; 470 size_t i; 471 472 /* All WIN64 architectures have SSE, right? */ 473 if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) { 474 __m128 values[4]; 475 for (i = num / 64; i--;) { 476 _mm_prefetch(src, _MM_HINT_NTA); 477 values[0] = *(__m128 *) (src + 0); 478 values[1] = *(__m128 *) (src + 16); 479 values[2] = *(__m128 *) (src + 32); 480 values[3] = *(__m128 *) (src + 48); 481 _mm_stream_ps((float *) (dst + 0), values[0]); 482 _mm_stream_ps((float *) (dst + 16), values[1]); 483 _mm_stream_ps((float *) (dst + 32), values[2]); 484 _mm_stream_ps((float *) (dst + 48), values[3]); 485 src += 64; 486 dst += 64; 487 } 488 num &= 63; 489 } 490 491 while (num--) { 492 *dst++ = *src++; 493 } 494 return destination; 495} 496#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */ 497 498#ifdef _M_IX86 499 500#ifdef FTOL_SSE 501void 502_ftol2_sse() 503{ 504 ftol(); 505} 506#endif 507 508/* Float to long */ 509void 510__declspec(naked) 511_ftol() 512{ 513 /* *INDENT-OFF* */ 514 __asm { 515 push ebp 516 mov ebp,esp 517 sub esp,20h 518 and esp,0FFFFFFF0h 519 fld st(0) 520 fst dword ptr [esp+18h] 521 fistp qword ptr [esp+10h] 522 fild qword ptr [esp+10h] 523 mov edx,dword ptr [esp+18h] 524 mov eax,dword ptr [esp+10h] 525 test eax,eax 526 je integer_QnaN_or_zero 527arg_is_not_integer_QnaN: 528 fsubp st(1),st 529 test edx,edx 530 jns positive 531 fstp dword ptr [esp] 532 mov ecx,dword ptr [esp] 533 xor ecx,80000000h 534 add ecx,7FFFFFFFh 535 adc eax,0 536 mov edx,dword ptr [esp+14h] 537 adc edx,0 538 jmp localexit 539positive: 540 fstp dword ptr [esp] 541 mov ecx,dword ptr [esp] 542 add ecx,7FFFFFFFh 543 sbb eax,0 544 mov edx,dword ptr [esp+14h] 545 sbb edx,0 546 jmp localexit 547integer_QnaN_or_zero: 548 mov edx,dword ptr [esp+14h] 549 test edx,7FFFFFFFh 550 jne arg_is_not_integer_QnaN 551 fstp dword ptr [esp+18h] 552 fstp dword ptr [esp+18h] 553localexit: 554 leave 555 ret 556 } 557 /* *INDENT-ON* */ 558} 559 560 561 562/* 64-bit math operators for 32-bit systems */ 563void 564__declspec(naked) 565_allmul() 566{ 567 /* *INDENT-OFF* */ 568 __asm { 569 mov eax, dword ptr[esp+8] 570 mov ecx, dword ptr[esp+10h] 571 or ecx, eax 572 mov ecx, dword ptr[esp+0Ch] 573 jne hard 574 mov eax, dword ptr[esp+4] 575 mul ecx 576 ret 10h 577hard: 578 push ebx 579 mul ecx 580 mov ebx, eax 581 mov eax, dword ptr[esp+8] 582 mul dword ptr[esp+14h] 583 add ebx, eax 584 mov eax, dword ptr[esp+8] 585 mul ecx 586 add edx, ebx 587 pop ebx 588 ret 10h 589 } 590 /* *INDENT-ON* */ 591} 592 593void 594__declspec(naked) 595_alldiv() 596{ 597 /* *INDENT-OFF* */ 598 __asm { 599 push edi 600 push esi 601 push ebx 602 xor edi,edi 603 mov eax,dword ptr [esp+14h] 604 or eax,eax 605 jge L1 606 inc edi 607 mov edx,dword ptr [esp+10h] 608 neg eax 609 neg edx 610 sbb eax,0 611 mov dword ptr [esp+14h],eax 612 mov dword ptr [esp+10h],edx 613L1: 614 mov eax,dword ptr [esp+1Ch] 615 or eax,eax 616 jge L2 617 inc edi 618 mov edx,dword ptr [esp+18h] 619 neg eax 620 neg edx 621 sbb eax,0 622 mov dword ptr [esp+1Ch],eax 623 mov dword ptr [esp+18h],edx 624L2: 625 or eax,eax 626 jne L3 627 mov ecx,dword ptr [esp+18h] 628 mov eax,dword ptr [esp+14h] 629 xor edx,edx 630 div ecx 631 mov ebx,eax 632 mov eax,dword ptr [esp+10h] 633 div ecx 634 mov edx,ebx 635 jmp L4 636L3: 637 mov ebx,eax 638 mov ecx,dword ptr [esp+18h] 639 mov edx,dword ptr [esp+14h] 640 mov eax,dword ptr [esp+10h] 641L5: 642 shr ebx,1 643 rcr ecx,1 644 shr edx,1 645 rcr eax,1 646 or ebx,ebx 647 jne L5 648 div ecx 649 mov esi,eax 650 mul dword ptr [esp+1Ch] 651 mov ecx,eax 652 mov eax,dword ptr [esp+18h] 653 mul esi 654 add edx,ecx 655 jb L6 656 cmp edx,dword ptr [esp+14h] 657 ja L6 658 jb L7 659 cmp eax,dword ptr [esp+10h] 660 jbe L7 661L6: 662 dec esi 663L7: 664 xor edx,edx 665 mov eax,esi 666L4: 667 dec edi 668 jne L8 669 neg edx 670 neg eax 671 sbb edx,0 672L8: 673 pop ebx 674 pop esi 675 pop edi 676 ret 10h 677 } 678 /* *INDENT-ON* */ 679} 680 681void 682__declspec(naked) 683_aulldiv() 684{ 685 /* *INDENT-OFF* */ 686 __asm { 687 push ebx 688 push esi 689 mov eax,dword ptr [esp+18h] 690 or eax,eax 691 jne L1 692 mov ecx,dword ptr [esp+14h] 693 mov eax,dword ptr [esp+10h] 694 xor edx,edx 695 div ecx 696 mov ebx,eax 697 mov eax,dword ptr [esp+0Ch] 698 div ecx 699 mov edx,ebx 700 jmp L2 701L1: 702 mov ecx,eax 703 mov ebx,dword ptr [esp+14h] 704 mov edx,dword ptr [esp+10h] 705 mov eax,dword ptr [esp+0Ch] 706L3: 707 shr ecx,1 708 rcr ebx,1 709 shr edx,1 710 rcr eax,1 711 or ecx,ecx 712 jne L3 713 div ebx 714 mov esi,eax 715 mul dword ptr [esp+18h] 716 mov ecx,eax 717 mov eax,dword ptr [esp+14h] 718 mul esi 719 add edx,ecx 720 jb L4 721 cmp edx,dword ptr [esp+10h] 722 ja L4 723 jb L5 724 cmp eax,dword ptr [esp+0Ch] 725 jbe L5 726L4: 727 dec esi 728L5: 729 xor edx,edx 730 mov eax,esi 731L2: 732 pop esi 733 pop ebx 734 ret 10h 735 } 736 /* *INDENT-ON* */ 737} 738 739void 740__declspec(naked) 741_allrem() 742{ 743 /* *INDENT-OFF* */ 744 __asm { 745 push ebx 746 push edi 747 xor edi,edi 748 mov eax,dword ptr [esp+10h] 749 or eax,eax 750 jge L1 751 inc edi 752 mov edx,dword ptr [esp+0Ch] 753 neg eax 754 neg edx 755 sbb eax,0 756 mov dword ptr [esp+10h],eax 757 mov dword ptr [esp+0Ch],edx 758L1: 759 mov eax,dword ptr [esp+18h] 760 or eax,eax 761 jge L2 762 mov edx,dword ptr [esp+14h] 763 neg eax 764 neg edx 765 sbb eax,0 766 mov dword ptr [esp+18h],eax 767 mov dword ptr [esp+14h],edx 768L2: 769 or eax,eax 770 jne L3 771 mov ecx,dword ptr [esp+14h] 772 mov eax,dword ptr [esp+10h] 773 xor edx,edx 774 div ecx 775 mov eax,dword ptr [esp+0Ch] 776 div ecx 777 mov eax,edx 778 xor edx,edx 779 dec edi 780 jns L4 781 jmp L8 782L3: 783 mov ebx,eax 784 mov ecx,dword ptr [esp+14h] 785 mov edx,dword ptr [esp+10h] 786 mov eax,dword ptr [esp+0Ch] 787L5: 788 shr ebx,1 789 rcr ecx,1 790 shr edx,1 791 rcr eax,1 792 or ebx,ebx 793 jne L5 794 div ecx 795 mov ecx,eax 796 mul dword ptr [esp+18h] 797 xchg eax,ecx 798 mul dword ptr [esp+14h] 799 add edx,ecx 800 jb L6 801 cmp edx,dword ptr [esp+10h] 802 ja L6 803 jb L7 804 cmp eax,dword ptr [esp+0Ch] 805 jbe L7 806L6: 807 sub eax,dword ptr [esp+14h] 808 sbb edx,dword ptr [esp+18h] 809L7: 810 sub eax,dword ptr [esp+0Ch] 811 sbb edx,dword ptr [esp+10h] 812 dec edi 813 jns L8 814L4: 815 neg edx 816 neg eax 817 sbb edx,0 818L8: 819 pop edi 820 pop ebx 821 ret 10h 822 } 823 /* *INDENT-ON* */ 824} 825 826void 827__declspec(naked) 828_aullrem() 829{ 830 /* *INDENT-OFF* */ 831 __asm { 832 push ebx 833 mov eax,dword ptr [esp+14h] 834 or eax,eax 835 jne L1 836 mov ecx,dword ptr [esp+10h] 837 mov eax,dword ptr [esp+0Ch] 838 xor edx,edx 839 div ecx 840 mov eax,dword ptr [esp+8] 841 div ecx 842 mov eax,edx 843 xor edx,edx 844 jmp L2 845L1: 846 mov ecx,eax 847 mov ebx,dword ptr [esp+10h] 848 mov edx,dword ptr [esp+0Ch] 849 mov eax,dword ptr [esp+8] 850L3: 851 shr ecx,1 852 rcr ebx,1 853 shr edx,1 854 rcr eax,1 855 or ecx,ecx 856 jne L3 857 div ebx 858 mov ecx,eax 859 mul dword ptr [esp+14h] 860 xchg eax,ecx 861 mul dword ptr [esp+10h] 862 add edx,ecx 863 jb L4 864 cmp edx,dword ptr [esp+0Ch] 865 ja L4 866 jb L5 867 cmp eax,dword ptr [esp+8] 868 jbe L5 869L4: 870 sub eax,dword ptr [esp+10h] 871 sbb edx,dword ptr [esp+14h] 872L5: 873 sub eax,dword ptr [esp+8] 874 sbb edx,dword ptr [esp+0Ch] 875 neg edx 876 neg eax 877 sbb edx,0 878L2: 879 pop ebx 880 ret 10h 881 } 882 /* *INDENT-ON* */ 883} 884 885void 886__declspec(naked) 887_alldvrm() 888{ 889 /* *INDENT-OFF* */ 890 __asm { 891 push edi 892 push esi 893 push ebp 894 xor edi,edi 895 xor ebp,ebp 896 mov eax,dword ptr [esp+14h] 897 or eax,eax 898 jge L1 899 inc edi 900 inc ebp 901 mov edx,dword ptr [esp+10h] 902 neg eax 903 neg edx 904 sbb eax,0 905 mov dword ptr [esp+14h],eax 906 mov dword ptr [esp+10h],edx 907L1: 908 mov eax,dword ptr [esp+1Ch] 909 or eax,eax 910 jge L2 911 inc edi 912 mov edx,dword ptr [esp+18h] 913 neg eax 914 neg edx 915 sbb eax,0 916 mov dword ptr [esp+1Ch],eax 917 mov dword ptr [esp+18h],edx 918L2: 919 or eax,eax 920 jne L3 921 mov ecx,dword ptr [esp+18h] 922 mov eax,dword ptr [esp+14h] 923 xor edx,edx 924 div ecx 925 mov ebx,eax 926 mov eax,dword ptr [esp+10h] 927 div ecx 928 mov esi,eax 929 mov eax,ebx 930 mul dword ptr [esp+18h] 931 mov ecx,eax 932 mov eax,esi 933 mul dword ptr [esp+18h] 934 add edx,ecx 935 jmp L4 936L3: 937 mov ebx,eax 938 mov ecx,dword ptr [esp+18h] 939 mov edx,dword ptr [esp+14h] 940 mov eax,dword ptr [esp+10h] 941L5: 942 shr ebx,1 943 rcr ecx,1 944 shr edx,1 945 rcr eax,1 946 or ebx,ebx 947 jne L5 948 div ecx 949 mov esi,eax 950 mul dword ptr [esp+1Ch] 951 mov ecx,eax 952 mov eax,dword ptr [esp+18h] 953 mul esi 954 add edx,ecx 955 jb L6 956 cmp edx,dword ptr [esp+14h] 957 ja L6 958 jb L7 959 cmp eax,dword ptr [esp+10h] 960 jbe L7 961L6: 962 dec esi 963 sub eax,dword ptr [esp+18h] 964 sbb edx,dword ptr [esp+1Ch] 965L7: 966 xor ebx,ebx 967L4: 968 sub eax,dword ptr [esp+10h] 969 sbb edx,dword ptr [esp+14h] 970 dec ebp 971 jns L9 972 neg edx 973 neg eax 974 sbb edx,0 975L9: 976 mov ecx,edx 977 mov edx,ebx 978 mov ebx,ecx 979 mov ecx,eax 980 mov eax,esi 981 dec edi 982 jne L8 983 neg edx 984 neg eax 985 sbb edx,0 986L8: 987 pop ebp 988 pop esi 989 pop edi 990 ret 10h 991 } 992 /* *INDENT-ON* */ 993} 994 995void 996__declspec(naked) 997_aulldvrm() 998{ 999 /* *INDENT-OFF* */ 1000 __asm { 1001 push esi 1002 mov eax,dword ptr [esp+14h] 1003 or eax,eax 1004 jne L1 1005 mov ecx,dword ptr [esp+10h] 1006 mov eax,dword ptr [esp+0Ch] 1007 xor edx,edx 1008 div ecx 1009 mov ebx,eax 1010 mov eax,dword ptr [esp+8] 1011 div ecx 1012 mov esi,eax 1013 mov eax,ebx 1014 mul dword ptr [esp+10h] 1015 mov ecx,eax 1016 mov eax,esi 1017 mul dword ptr [esp+10h] 1018 add edx,ecx 1019 jmp L2 1020L1: 1021 mov ecx,eax 1022 mov ebx,dword ptr [esp+10h] 1023 mov edx,dword ptr [esp+0Ch] 1024 mov eax,dword ptr [esp+8] 1025L3: 1026 shr ecx,1 1027 rcr ebx,1 1028 shr edx,1 1029 rcr eax,1 1030 or ecx,ecx 1031 jne L3 1032 div ebx 1033 mov esi,eax 1034 mul dword ptr [esp+14h] 1035 mov ecx,eax 1036 mov eax,dword ptr [esp+10h] 1037 mul esi 1038 add edx,ecx 1039 jb L4 1040 cmp edx,dword ptr [esp+0Ch] 1041 ja L4 1042 jb L5 1043 cmp eax,dword ptr [esp+8] 1044 jbe L5 1045L4: 1046 dec esi 1047 sub eax,dword ptr [esp+10h] 1048 sbb edx,dword ptr [esp+14h] 1049L5: 1050 xor ebx,ebx 1051L2: 1052 sub eax,dword ptr [esp+8] 1053 sbb edx,dword ptr [esp+0Ch] 1054 neg edx 1055 neg eax 1056 sbb edx,0 1057 mov ecx,edx 1058 mov edx,ebx 1059 mov ebx,ecx 1060 mov ecx,eax 1061 mov eax,esi 1062 pop esi 1063 ret 10h 1064 } 1065 /* *INDENT-ON* */ 1066} 1067 1068void 1069__declspec(naked) 1070_allshl() 1071{ 1072 /* *INDENT-OFF* */ 1073 __asm { 1074 cmp cl,40h 1075 jae RETZERO 1076 cmp cl,20h 1077 jae MORE32 1078 shld edx,eax,cl 1079 shl eax,cl 1080 ret 1081MORE32: 1082 mov edx,eax 1083 xor eax,eax 1084 and cl,1Fh 1085 shl edx,cl 1086 ret 1087RETZERO: 1088 xor eax,eax 1089 xor edx,edx 1090 ret 1091 } 1092 /* *INDENT-ON* */ 1093} 1094 1095void 1096__declspec(naked) 1097_allshr() 1098{ 1099 /* *INDENT-OFF* */ 1100 __asm { 1101 cmp cl,3Fh 1102 jae RETSIGN 1103 cmp cl,20h 1104 jae MORE32 1105 shrd eax,edx,cl 1106 sar edx,cl 1107 ret 1108MORE32: 1109 mov eax,edx 1110 sar edx,1Fh 1111 and cl,1Fh 1112 sar eax,cl 1113 ret 1114RETSIGN: 1115 sar edx,1Fh 1116 mov eax,edx 1117 ret 1118 } 1119 /* *INDENT-ON* */ 1120} 1121 1122void 1123__declspec(naked) 1124_aullshr() 1125{ 1126 /* *INDENT-OFF* */ 1127 __asm { 1128 cmp cl,40h 1129 jae RETZERO 1130 cmp cl,20h 1131 jae MORE32 1132 shrd eax,edx,cl 1133 shr edx,cl 1134 ret 1135MORE32: 1136 mov eax,edx 1137 xor edx,edx 1138 and cl,1Fh 1139 shr eax,cl 1140 ret 1141RETZERO: 1142 xor eax,eax 1143 xor edx,edx 1144 ret 1145 } 1146 /* *INDENT-ON* */ 1147} 1148 1149#endif /* _M_IX86 */ 1150 1151#endif /* MSC_VER */ 1152 1153#endif /* !HAVE_LIBC */ 1154 1155/* vi: set ts=4 sw=4 expandtab: */ 1156[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.