Hi
I'm using the C6xSimulator.c file to compile mex files for the C6472. I think I've discovered an error with the _sat() intrinsic when passing a negative value less then
Below are 2 screens showing the decimal and hex result when I pass 0xffff fff0 0000 0004 to the _sat() routine. The returned result in y32 is 0x0000 0004 when it should be 0x8000 0000. It looks like the if statement for the minimum is incorrect.
Would this be the correct code? (replace a40.x2.lo == 0 with !(a40.x2.lo & MIN_INT32)
if(a40.x2.hi > 0 || ((a40.x2.hi == 0) && (a40.x2.lo & MIN_INT32))) y32 = MAX_INT32; //else if ((a40.x2.hi < 0) && (a40.x2.lo == 0)) else if ((a40.x2.hi < 0) && !(a40.x2.lo & MIN_INT32)) y32 = MIN_INT32; else y32 = a40.x2.lo;
Cheers2u
Eddie
typedef struct _INT40X2 { int32 lo; int8 hi; int8 unused0; int8 unused1; int8 unused2; } int40x2;
union reg40 { int40 x1; int40x2 x2; uint40 x1u; int40x2u x2u; };
Hex version of same numbers below