mul24 Not working?

Hi,

i’m trying to use the mul24 function with emulation in my project and something troubles me…

On page 75 of the programming guide (0.8.2) is said that:

__[u]mul24(x, y) computes the product of the 24 least significant bits of the integer parameters x and y and delivers the 32 least significant bits of the result. If any of the 8 most significant bits of either x or y are set, the result is undefined.

So if i try to set x = 0x00FFFFFF and y = 0x00000001 ,
I expect to get 0xFFFFFFFF as a result because it delivers the 32 most significant bit… but instead I get 0x00FFFFFF, so the result is not sign-extended.

Am I doing something wrong?

Thanks a lot!

Are x and y signed or unsigned? Did you use mul24 or umul24?

I’m using the __mul24 (signed) with signed operands.

If you multiply 0X00FFFFFF and 0X00000001 you should get back 0X00FFFFFF.

Compiling:

int main()
{
printf (“%#X\n”,0x00ffffff);
printf (“%#X\n”,0x00000001);
printf (“%#X\n”,0x00ffffff
*0x00000001);
}

the output is:
0XFFFFFF
0X1
0XFFFFFF