Fixed bug 2537 - _allmul in SDL_lib.c is not working properly
authorSam Lantinga <slouken@libsdl.org>
Sun, 27 Jul 2014 17:44:10 -0700
changeset 9015 45f11ff360a8
parent 9014 795fb603eda8
child 9016 648dbad92045
Fixed bug 2537 - _allmul in SDL_lib.c is not working properly
src/stdlib/SDL_stdlib.c
--- a/src/stdlib/SDL_stdlib.c	Sun Jul 27 17:43:36 2014 -0700
+++ b/src/stdlib/SDL_stdlib.c	Sun Jul 27 17:44:10 2014 -0700
@@ -370,44 +370,35 @@
     _ftol();
 }
 
-/* 64-bit math operators for 32-bit systems */
-void
-__declspec(naked)
-_allmul()
-{
-    /* *INDENT-OFF* */
-    __asm {
-        push        ebp
-        mov         ebp,esp
-        push        edi
-        push        esi
-        push        ebx
-        sub         esp,0Ch
-        mov         eax,dword ptr [ebp+10h]
-        mov         edi,dword ptr [ebp+8]
-        mov         ebx,eax
-        mov         esi,eax
-        sar         esi,1Fh
-        mov         eax,dword ptr [ebp+8]
-        mul         ebx
-        imul        edi,esi
-        mov         ecx,edx
-        mov         dword ptr [ebp-18h],eax
-        mov         edx,dword ptr [ebp+0Ch]
-        add         ecx,edi
-        imul        ebx,edx
-        mov         eax,dword ptr [ebp-18h]
-        lea         ebx,[ebx+ecx]
-        mov         dword ptr [ebp-14h],ebx
-        mov         edx,dword ptr [ebp-14h]
-        add         esp,0Ch
-        pop         ebx
-        pop         esi
-        pop         edi
-        pop         ebp
-        ret         10h
-    }
-    /* *INDENT-ON* */
+/* 64-bit math operators for 32-bit systems */
+void
+__declspec(naked)
+_allmul()
+{
+    /* *INDENT-OFF* */
+    __asm {
+        mov         eax, dword ptr[esp+8]
+        mov         ecx, dword ptr[esp+10h]
+        or          ecx, eax
+        mov         ecx, dword ptr[esp+0Ch]
+        jne         hard
+        mov         eax, dword ptr[esp+4]
+        mul         ecx
+        ret         10h
+hard:
+        push        ebx
+        mul         ecx
+        mov         ebx, eax
+        mov         eax, dword ptr[esp+8]
+        mul         dword ptr[esp+14h]
+        add         ebx, eax
+        mov         eax, dword ptr[esp+8]
+        mul         ecx
+        add         edx, ebx
+        pop         ebx
+        ret         10h
+    }
+    /* *INDENT-ON* */
 }
 
 void