I tried to use RTS library for double multiplication in C6416 simulator using _mpyd() intrinsic but the result is zero for any input.I can not understand why is this happening.
My source code is very simple
#include<stdio.h>
#include<iso646.h>
#define SW_MAX 32767
#define SW_MIN -32768
#define MAX_40 549755813883.0
#define MIN_40 -549755813884.0
double L40_mac1( short int var1, short int var2)
{
double result=0;
result = _mpyd((double)var1,((double)var2 * 2));
if (result > MAX_40){
result = MAX_40; /* Overflow = 1; */
}
if (result < MIN_40){
result = MIN_40; /* undererflow = 1; */
}
return(result);
}
int main()
{
short int a=SW_MAX,b=SW_MIN;
double c=0;
c=_mpyd( (double)b , (double)a );
// c=L40_mac1(a,b);
printf("c1=%f\n",c);
return (0);
}
The result obtained is c1=0.
I have also tried it for other input values but still answer was zero.
My build option are -g -ol1 -fr"$(Proj_dir)\Debug" -d"_DEBUG" -ms0 -mv6400.
Kindly help me as soon as possible because it is part of my project for optimization.Any other suggestion will be appreciated.
Thanx in advance