为什么这个代码没有设置temp
到 1?我该怎么做?
int temp;
__asm__(
".intel_syntax;"
"mov %0, eax;"
"mov eax, %1;"
".att_syntax;"
: : "r"(1), "r"(temp) : "eax");
printf("%d\n", temp);
最佳答案
你要temp
我认为是输出,而不是输入。尝试:
__asm__(
".intel_syntax;"
"mov eax, %1;"
"mov %0, eax;"
".att_syntax;"
: "=r"(temp)
: "r"(1)
: "eax");
关于gcc - 如何使用 Intel 语法内联汇编在 GCC 中设置变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5397677/