DEV-C++内联汇编问题
#include <stdio.h>#include <stdlib.h>
int a = 10;
int b = 20;
int result;
int main()
{
asm
(
"pusha\n\t"
"movl a,%eax\n\t"
"movl b,%ebx\n\t"
"imull %ebx,%eax\n\t"
"movl %eax,result\n\t"
"popa"
);
printf("%d\n",result);
return 0;
}
上面的代码是教科书里的,教程中说内联汇编要访问的变量必须是全局的,我认为程序没有问题,但编译运行时报错:
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "E:\xx\test\test.c" -o "E:\xx\test\test.exe" -I"d:\Dev-Cpp\include" -L"d:\Dev-Cpp\lib"
C:\DOCUME~1\xxx\LOCALS~1\Temp/ccUlaaaa.o(.text+0x38):test.c: undefined reference to `a'
C:\DOCUME~1\xxx\LOCALS~1\Temp/ccUlaaaa.o(.text+0x3e):test.c: undefined reference to `b'
C:\DOCUME~1\xxx\LOCALS~1\Temp/ccUlaaaa.o(.text+0x46):test.c: undefined reference to `result'collect2: ld returned 1 exit status
Execution terminated
请教大家,问题出在哪里??3x