Technical discussions related to Analog Devices DSPs (including Blackfin, TigerSHARC, SHARC and ADSP-21xx DSPs).
Good morning I have a problem with multiplication in TS201. I'm trying to evaluate the following expression unsigned int a = 0xABABABAB; unsigned int b = 0xACACACAC; unsigned long long c = a*b; However c doesn't store the correct result but it stores only the 32 least significant bits of the 32x32 bit multiplication. What's wrong? I obtain the correct result only if I cast a and b to unsigned long long but acting by this way the compiler emulates 64x64 bit operation slowing down the whole process. Any hint will be appreciated. Gio
Hi Gio, What you want to do is to look up 'intrinsic functions' in the TigerSharc compiler manual (starts on p1-126). These functions map directly to the machine code instruction that does the specific operation you want. For instance, here is the intrinsic for returning a 64 bit result from a multiply of two 32 bit integer numbers and the corresponding assembly instruction it maps to. long long int __builtin_mult_i1x32_wide(int Rm, int Rn); Rsd = Rm * Rn (I); Hope this helps. Cheers, George Kadziolka Kaztek Systems www.kaztek.com <http://www.kaztek.com/> _____ From: a...@yahoogroups.com [mailto:a...@yahoogroups.com] On Behalf Of Giovanni Parodi Sent: Tuesday, August 07, 2007 6:07 AM To: a...@yahoogroups.com Subject: [adsp] 32x32 bit multiplication on TS201 Good morning I have a problem with multiplication in TS201. I'm trying to evaluate the following expression unsigned int a = 0xABABABAB; unsigned int b = 0xACACACAC; unsigned long long c = a*b; However c doesn't store the correct result but it stores only the 32 least significant bits of the 32x32 bit multiplication. What's wrong? I obtain the correct result only if I cast a and b to unsigned long long but acting by this way the compiler emulates 64x64 bit operation slowing down the whole process. Any hint will be appreciated. Gio
Good morning
I have a problem with multiplication in TS201.
I'm trying to evaluate the following expression
unsigned int a = 0xABABABAB;
unsigned int b = 0xACACACAC;
unsigned long long c = a*b;
However c doesn't store the correct result but it stores only the 32 least significant bits of the 32x32 bit multiplication.
What's wrong?
I obtain the correct result only if I cast a and b to unsigned long long but acting by this way the compiler emulates 64x64 bit operation slowing down the whole process.
Any hint will be appreciated.
Gio
![]()
(You need to be a member of adsp -- send a blank email to adsp-subscribe@yahoogroups.com )