From 9631ed66edf26179da201ceee27b829403b6c78f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Jun 2015 21:45:57 -0400 Subject: [PATCH] [PJGlide64] imul16: no need for inline asm here --- Source/Glide64/FixedPoint.asm.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/Source/Glide64/FixedPoint.asm.cpp b/Source/Glide64/FixedPoint.asm.cpp index d20e5694e..ba05e2cb1 100644 --- a/Source/Glide64/FixedPoint.asm.cpp +++ b/Source/Glide64/FixedPoint.asm.cpp @@ -41,26 +41,6 @@ typedef signed __int64 int64_t; #include #endif -#ifdef _M_IX86 -// (x * y) >> 16 -extern "C" int __declspec(naked) imul16(int x, int y) -{ - _asm { - push ebp - mov ebp,esp - mov eax, [x] - mov edx, [y] - imul edx - shrd eax,edx,16 - leave - ret - } -} - -#else -DebugBreak(); -#endif - int imul14(int x, int y) { int64_t result; @@ -71,6 +51,16 @@ int imul14(int x, int y) return (int)(result); } +int imul16(int x, int y) +{ + int64_t result; + const int64_t m = (int64_t)(x); + const int64_t n = (int64_t)(y); + + result = (m * n) >> 16; + return (int)(result); +} + int idiv16(int x, int y) { int64_t result;