On 4/22/08, David Smead <[email protected]> wrote: > Cast one or both operands to 32-bit and C will give you a 32 bit result. Or > copy one to a 32-bit and use that as the result.
but, if you promote operands to 32-bit, the compiler will use 32x32->32 multiply, which is not implemented in hardware on msp430 (presumably it'll be a library call). The relevant question is how to trigger the code generator to emit the MPY instruction that takes two 16-bit operands and produces a 32-bit result. Since such operation is not the default behavior in ANSI C, and assuming the compiler is capable of this at all, you have to write a special idiom that would be special-cased by the code generator. I have seen a convention involving double casting: (int32)(int16)op1 * (int32)(int16)op2. Again, this is not ANSI. NB, the library call above will probably use MPY internally if it's available, so it may be not that much overhead if it's written well---I mean not hundred times slower, just few hundred percent overhead :)
