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.

CCSv6 gcc assembly for msp430?



Hi:

Is there any way to use MSP430 header files with GCC in assembly? I haven't been able to get this to work - adding

#include <msp430.h>

results in lots of "unknown opcodes"  due to stuff like 'const', 'typedef', etc. There don't appear to be any assembly guards in the include_gcc headers, and even using the include/ headers with an _ASM_HEADER_ definition still doesn't work.

Is it just not possible to use a pure assembly file at all with GCC set as the compiler? 

  • I think you mean to write hand-coded assembly that includes C header files like <msp430.h>.  The TI MSP430 assembler can do that with the .cdecls directive.  The GCC MSP430 assembler has no directive like .cdecls.  I did a web search on the term gnu assembler include c header and found some links that look interesting.  But I can't say how well any of those techniques work.

    Thanks and regards,

    -George

  • Well, the GCC assembler doesn't have that directive but it can run things through the preprocessor fine.

    There are two actual problems, though:

    1) CCSv6 doesn't know that for assembly files you need to have -D_GNU_ASSEMBLER_ on the compile line so that the non-assembly stuff is protected OK. You can of course add it yourself, but, well, I don't see information for that anywhere, so I just had to figure that out for myself.

    2) const_sfrb in iomacros.h is not protected with an ifdef for the assembler: they're located outside of the #ifdef _GNU_ASSEMBLER_ area.

    This has been noticed elsewhere, before (many months ago):

    http://sourceforge.net/p/mspgcc/mailman/message/31842549/

    and people have apparently just edited it, and fixed it elsewhere for a while, although I haven't found any documentation that says to do that, so again, it's just a "you just have to figure it out."

    https://gist.githubusercontent.com/RickKimball/1303030/raw/b8b7d946b5c4aac5bde0adae27506ee2385a13d9/include/iomacros.h

    Is there a place to actually file a bug on this so that it maybe could get updated? 

  • The file iomacros.h is not maintained by the compiler development team.  But I think I can shed some light.

    I think your problem is fixed in CCS 6.0.1.x.  The iomacros.h in that version has a group of lines in it protected by

    #if defined(__ASSEMBLER__)
    

    Does the iomacros.h you have include these lines?

    Thanks and regards,

    -George