Reputation: 79
I tried an example from GCC-Inline-Assembly-HOWTO
int main(void)
{
int foo = 10, bar=15;
_asm__volatile_( "addl %%ebx,%%eax;\n"
:"=a"(foo)
:"a"(foo), "b"(bar));
printf("foo+bar+%d\n",foo);
return 0;
}
the above code gives me this error
: add_two.c:8:3: error: expected ‘)’ before ‘:’ token
.
where have i gone wrong? I am working on ubuntu 12.04
.
Upvotes: 1
Views: 1337
Reputation: 181077
_asm__volatile_( "addl %%ebx,%%eax;\n"
...is not correct syntax. asm and volatile are separate keywords.
__asm__ __volatile__( "addl %%ebx,%%eax;\n"
...compiles (and executes with correct result).
Upvotes: 4