This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mixing C and assembly.
- From: Joel Sherrill <joel dot sherrill at OARcorp dot com>
- To: Salim Belgroune <salim dot belgroune at crm dot mot dot com>
- Cc: gcc at gnu dot org, gcc-help at gcc dot gnu dot org, gnu at gnu dot org
- Date: Fri, 05 Dec 2003 10:54:18 -0600
- Subject: Re: mixing C and assembly.
- Organization: OAR Corporation
- References: <3FD0B43D.4080209@crm.mot.com>
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