On Mon, Apr 21, 2008 at 2:42 PM, Christian Böhme <[email protected]> wrote: > > > you need to read the compiler code generation templates (tricky). > > What's so tricky about that ?
Code generation templates are provided in Machine Description files, like those two for gcc 3.2.3 and 4.1.1: http://mspgcc.cvs.sourceforge.net/mspgcc/gcc/gcc-4.1.1/gcc/config/msp430/msp430.md?revision=1.2&view=markup http://mspgcc.cvs.sourceforge.net/mspgcc/gcc/gcc-current/gcc/config/msp430/msp430.md?revision=1.2&view=markup I find them obtuse and tricky, and I am relieved to hear you disagree, because the answer to your question is in the .md file that the MPY-capable version of mspgcc uses. I haven't run into the MPY issues before, so I don't even know which gcc versions can use it---I haven't found the relevant MD templates in the files I looked at. In general, however, you are right that in standard ANSI C the multiply result size is determined by the operands, resulting in truncation. In that case, you may need to use inline assembly to accomplish your 16x16->32 operation. Again, I haven't used MUL so the example below is just supposed to give you a general idea and is almost certainly wrong for generating the MPY instruction on msp430 asm ("MPY %1,%0" : "=r" (result) : "r" (op1),"r"(op2)) Brennan's inline assembly tutorial for x86 is at http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html; I don't know of a good explanation of operand descriptors for MSP inline assembly.
