MSP430 in gcc4.9 ... enable interrupts?

David Brown david.brown@hesbynett.no
Sun Feb 16 14:26:00 GMT 2014


On 14/02/14 20:17, DJ Delorie wrote:
> The constructs in the *.md files are for the compiler's internal use
> (i.e. there are function attributes that trigger those).  You don't
> need compiler support for these opcodes at the user level; the right
> way is to implement those builtins as inline assembler in a common
> header file:
>
> static inline __attribute__((always_inline))
> void __nop()
> {
>    asm volatile ("NOP");
> }
>
> static inline __attribute__((always_inline))
> void __eint()
> {
>    asm volatile ("EINT");
> }
>
>
> Or more simply:
>
> #define __eint() asm("EINT")
> #define __nop() asm("NOP")
>
>
> For opcodes with parameters, you use a more complex form of inline
> assembler:
>
> static inline __attribute__((always_inline))
> void BIC_SR(const int x)
> {
>    asm volatile ("BIC.W %0,R2" :: "i" (x));
> }
>

I presume these will be part of the headers for the library distributed 
for msp430 gcc by TI/Redhat?  (I know that's a bit off-topic for the gcc 
list, but it is relevant to msp430 gcc users who don't want to have to 
learn inline assembly.)  I certainly think that's the right way to 
handle this sort of thing - if it can be just as efficiently put in 
headers using inline assembly, then maintenance is easier than putting 
it into gcc itself.

When you say that the interrupt control in the compiler is for function 
attributes, is that for the "critical" attribute that exists in the old 
msp430 port (which disables interrupts for the duration of the 
function)?  I don't see it mentioned in the current gcc documentation, 
but I haven't tried the code itself.  It was certainly a nice idea - and 
one that I would love to see supported on a range of gcc ports rather 
than just the msp430.

David




More information about the Gcc mailing list