It's good that GCC support inline assembly Intel syntax, but it cannot even simply address local variables/parameters properly, making itself stupid and essentially useless, look at the following example:
Code: Select all
// In MSVC, this compiles successfully
int main(int argc, char *argv[])
{
int x=1, f=2, fa=3;
__asm{
int 3
mov eax, [x+4]
movss xmm1,[f+4]
fld [fa+4]
}
return 0;
}
Code: Select all
// In GCC AT&T syntax, this compiles successfully
int main(int argc, char *argv[])
{
int x=1, f=2, fa=3;
asm("int $0x3");
asm("mov 4%0,%%eax"::"m"(x));
asm("movss 4%0,%%xmm1"::"m"(f));
asm("fld 4%0"::"m"(fa));
return 0;
}
Code: Select all
// In GCC Intel syntax, this would fail to compile
int main(int argc, char *argv[])
{
int x=1, f=2, fa=3;
asm(".intel_syntax noprefix\n"
"int 3\n"
"mov eax, [x+4]\n"
"movss xmm1,[f+4]\n"
"fld [fa+4]\n"
".att_syntax\n");
return 0;
}
Best regards,
Wang Xuancong