This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mixing C and assembly.


Salim Belgroune wrote:

Hello,

I'm currently using the MPC8260 ( with a PPC 603e core ).

Could you give me a tutorial or examples on writing assembly routines that will be written and compiled inside a C source code.

There are no tutorials that I know of. There are sources for examples including the PowerPC specific code in RTEMS. Here is an example of disabling external interrupts via the MSR:

#define _CPU_ISR_Disable( _isr_cookie ) \
  { register unsigned int _disable_mask = PPC_MSR_DISABLE_MASK; \
    _isr_cookie = 0; \
    asm volatile ( \
        "mfmsr %0; andc %1,%0,%1; mtmsr %1" : \
        "=&r" ((_isr_cookie)), "=&r" ((_disable_mask)) : \
        "0" ((_isr_cookie)), "1" ((_disable_mask)) \
        ); \
  }

It returns the previous value of the MSR as "_isr_cookie" so you
can enable later to the previous level:

#define _CPU_ISR_Enable( _isr_cookie )  \
  { \
     asm volatile ( "mtmsr %0" : \
                   "=r" ((_isr_cookie)) : \
                   "0" ((_isr_cookie))); \
  }

There are lots of other examples in the RTEMS source.

Kind regards.

Salim Belgroune.



--
Joel Sherrill, Ph.D.             Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]