I'm using an MCU that doesn't support long long
type. I can't cast to long long
.
I need a function to get the high 32 bits of a 32-bit/32-bit multiplication.
x86 ASM is like this:
__asm {
mov eax, a
mov ecx, b
mul ecx
mov eax, edx
}
Is there a C code that would do the same function? I tried
UINT32 umulm(UINT32 a, UINT32 b)
{
UINT32 i, r;
r = 0;
for (i = 1; i < 32; i++)
if (a & (1 << i))
r += b >> (32 - i);
return r;
}
, but something is wrong with function; how could I fix it?