This is the mail archive of the gcc-help@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: in line assembly


"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


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