I need a routine to multiply two 32 bit unsigned integers and return a 64 bit result.
It appears that if I try doing
unsigned long long int r;
unsigned long int a,b;
and then r=a*b;
The compiler generates a call to a buitin function __mulsi3, which according to the
source only returns a 32 bit number.
Now what I am really trying to do is to perform a fixed point multipy of an
unsigned long number by a fixed point constant. The constant is represented by
a fixed point long with an assumed decimal point 24 bits to the right of bit 0. (IE: an
8 bit integer with a 24 bit fraction). I would discard the lowest 24 bits of the result
and keep the next 32 sig bits.
Short of modifing the assembler source for the library multiply routine (I am using a
mega32 cpu, so I think the mul instruction is available) to provide a true 32x32=64 bit
routine, is there another way?