This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler Warning : #64-D shift count is too large

Other Parts Discussed in Thread: MSP430F4784

Hello,

I am writing an application for computing power on MSP430F4784. IDE is CCSv5.4.

Signed multiplication is performed using 16 x 16 hardware multiplier peripheral.

Following formula computes power:

UkArray[0][index] = Uk;
IkAvg[0][index] = ((signed int)((((signed int)(Ik)) + ((signed int)(Iold))) >> 1));

MPYS = UkArray[0][index];
OP2 = IkAvg[0][index];

PkAvg[0][index] = ((signed long)(((signed long)(RESHI << 16)) | ((signed long)(RESLO))));

 

After compiling the program, i am getting following warning:

#64-D shift count is too large

Results observed in hardware multiplier result registers RESHI and RESLO are correct.

But results stored in array variable PkAvg[0][index] are wrong.

e.g., MPY = -8520

         OP2 = -2052

         RESHI = 0x010A       -- This is correct

         RESLO = 0xC520     -- This is correct

         However, PkAvg[0][index] = 528240        -- This is wrong

16 x 16 signed multiplier is calculating correct results, but why is the compiler storing wrong results in array variable PkAvg[0][index] even after type casting RESHI and RESLO to signed long which is 32 bits ?

 

Thank You,

Sunil

  • You have:

    PkAvg[0][index] = ((signed long)(((signed long)(RESHI << 16)) | ((signed long)(RESLO))));


    Where RESHI is only 16 bits wide. You cannot shift it 16 bits to the left.You need to promote it to 32 bits wide before, not after, it is to be shifted.

**Attention** This is a public forum