On 4/23/08, Ralf Hildebrandt <[email protected]> wrote: > var32 = (var32_type)var16_a * var16_b; > > Cast /one/ operand to 32 bits before multiplication and prey for that > you don't have a really bad compiler. GCC should infer a 16Bit*16Bit => > 32Bit multiplication. IAR does the same
I think that means that IAR is not ANSI C conformant, because for better or worse ANSI specifies the type promotion so that it forces a 32x32->32 operation here. I seem to remember a compiler from the old days that would recognize the code pattern int 16 a,b,hi,lo; hi = a / b; lo = a % b; and generate the 16x16->32 multiply distributing the result halves into the hi,lo variables. I can't remember the context though.
