Mail Archives: djgpp/1997/08/23/17:05:21
Jason Meehan wrote:
>
> int i=0,j=1,k=0;
> _asm__volatile_("
> movl%1,%%eax\n
> addl%2,%%eax\n
> movl%%eax, %0"
> :"g=" (k) ( I get an error here) error:parse error before ':'
> :"g"(i),"g"(j)
> :"ax","memory"
> );
>
> The above is an example that I copied out of some docs, but I get the
> same problem with my own inline asm. Can anyone help me? Thanks
Write __asm__<space>__volatile__ (two underscores before and after asm
and volatile), add a space after the assembly opcode. I suggest you to
do something like:
int i=0,j=1,k=0;
__asm__ __volatile__ ("movl %1,%%eax\n\t"
"addl %2,%%eax\n\t"
"movl %%eax, %0"
:"g=" (k)
:"g"(i),"g"(j)
:"ax","memory"
);
enclose every line in quotes, and put \n and \t for proper indentation
of .S files (sometimes is useful to take a look at those files). If you
prefer to use only one pair of quotes enclosing all the assembly code
\n is not required as long as you write every instruction in a
separated line:
__asm__ __volatile__ ("movl %1,%%eax
addl %2,%%eax
movl %%eax, %0"
:"g=" (k)
:"g"(i),"g"(j)
:"ax","memory"
);
Hope this works.
Saludos
Alexis Roda
- Raw text -