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.

Multiplication in MSP430FG4618 using IAR

Hi,

I am trying to do a 8-bit X 16-bit multiplication on the FG4618 using IAR compiler.

My code goes something like this:

Z  = Y * 0x3E8

where Z is of type DWORD and Y is of type BYTE

For all values of Y upto 0x1F, I get correct results.

However, if I change the value of Y to 0x20 or above, I get a strange result, something like 0x2F90E30.

I checked the disassembly for this in the debugger and it generates correct assembly code for values of Y upto 0x1F. But for anything equal to 0x20 and above, the assembly code goes haywire.

I am really confused! I tried including "math.h", but it did not help.

I tried doing Z = (Y << 0x0A) and I get the same result.

I can use the hardware multiplier to do this and I might get the correct result, but I dont understand why doesnt the compiler do it correctly.

Am I missing out on something? Can someone please help me on this!!!

With Thanks and Regards,

Tushar

 

**Attention** This is a public forum