#include<stdio.h>
#include<stdlib.h>
int main (void)
{
int a=10, b;
asm ("movl %1, %%eax;
movl %%eax, %0;"
:"=r"(b) /* output */
:"r"(a) /* input */
:"%eax" /* clobbered register */
);
printf("%d", b);
system("pause");
}
I am fairly a newbie, and I copy the sample code in the book bought yesterday, but when I compiled my first asm code, I just got some warnings and errors reported from GCC-mingw32 Compiler listed below:
In function 'main':
line 7 --> warning: missing terminating " character
line 7 --> error: missing terminating " character
line 8 --> error: expected string literal before 'movl'
line 8 --> warning: missing terminating " character
line 8 --> error: missing terminating " character
How can I compile it successfully? Thanks in advance :-)
Each instruction should be placed in double quotes ""
as "movl %1, %%eax;"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With