Does this work for you?mcostalba wrote:Still doesn't worksGerd Isenberg wrote: with this?Code: Select all
Score make_score(int ac, int bd) {return (ac << 16) | (bd & 0xffff);}
Code: Select all
int swarIMulDiv16(int s1, int s2)
{
__int64 v64 = __int64(s1) * __int64(s2);
int bd = int(v64);
int ac = int(v64>>32) - (bd>>31);
return (ac<<12) ^ ((bd>>4) & 0xffff);
}

Code: Select all
?swarIMulDiv16@@YAHHH@Z PROC NEAR
00000 8b 44 24 04 mov eax, DWORD PTR _s1$[esp-4]
00004 f7 6c 24 08 imul DWORD PTR _s2$[esp-4]
00008 8b c8 mov ecx, eax ; ???
0000a 8b c2 mov eax, edx ; ???
0000c c1 fa 1f sar edx, 31 ; ????
0000f 8b d1 mov edx, ecx
00011 c1 fa 1f sar edx, 31
00014 2b c2 sub eax, edx
00016 c1 f9 04 sar ecx, 4
00019 c1 e0 0c shl eax, 12
0001c 81 e1 ff ff 00 00 and ecx, 65535
00022 33 c1 xor eax, ecx
00024 c3 ret 0
?swarIMulDiv16@@YAHHH@Z ENDP