This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: in line assembly
- From: Ian Lance Taylor <ian at airs dot com>
- To: "Kevin Ma" <kevin dot ma at globalipsound dot com>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 15 Mar 2006 20:52:53 -0800
- Subject: Re: in line assembly
- References: <000801c6488b$bb755240$4e64010a@gips.com>
"Kevin Ma" <kevin.ma@globalipsound.com> writes:
> I'm new in using GCC. This is for an embedded system development. When I
> tried to use in line assembly, I found I can't write a relatively large
> block of assembly within C. For example, if I wrote,
>
> asm(
> lea -60(a7), a7 ;
> movem.l d0-d6/a0-a5, (a7) ;
> move.l MACSR, d6 ;
> move.l %0x00, d0 ;
> move.l d0, MACSR ;
> (and a lot of lines ...)
> )
> The compiler would not recognize it. Seems I have to write strictly in the
> syntax as
>
> asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
>
> which is the only way specified in the GCC manual.
>
> How can I overcome this problem and write a large chunk of assembly code in
> a C file? Thanks.
1) Use an assembler file instead, or
2) Use strings:
asm(
"lea -60(a7), a7 ;"
"movem.l d0-d6/a0-a5, (a7) ;"
"move.l MACSR, d6 ;"
"move.l %0x00, d0 ;"
"move.l d0, MACSR ;"
(and a lot of lines ...)
)
Ian