Grant Edwards wrote:
On 2008-04-22, Przemek Klosowski <[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.
That question has come up a couple times in the past, and IIRC,
the answer is that there's no practical way to get GCC to do
that.
avr-gcc manages to implement 8x8->16 bit multiply (it's an 8-bit cpu, so
that's the size of its multiply unit). I've noticed mixed-size
multiplies and divides on various gcc's (possibly including msp430 - I
haven't checked).