小编use*_*915的帖子

C中的内联汇编

#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");
}
Run Code Online (Sandbox Code Playgroud)

我是一个相当新手,我复制了昨天买的书中的示例代码,但是当我编译我的第一个asm代码时,我刚收到一些警告和错误报告来自下面列出的GCC-mingw32编译器:

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
Run Code Online (Sandbox Code Playgroud)

我怎样才能成功编译?提前致谢 …

c x86 assembly gcc inline-assembly

4
推荐指数
1
解决办法
1814
查看次数

标签 统计

assembly ×1

c ×1

gcc ×1

inline-assembly ×1

x86 ×1