Zac*_*Zac 1 c++ netbeans inline-assembly
我试图通过youtube上发布的一系列非常好的教程来学习汇编:
我熟悉netbeans中的C++和Java编程,我正在使用MinGW编译器集.我在netbeans编译器属性中设置了我的C++和汇编编译器.
我的C++代码正在编译,但是使用_asm {}
来尝试内联汇编代码并不能正确编译.
我收到的错误是:
main.cpp: In function 'int getValueFromASM()':
main.cpp:18:5: error: '_asm' was not declared in this scope
main.cpp:18:10: error: expected ';' before '{' token
make[2]: *** [build/Debug/MinGW_1-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
Run Code Online (Sandbox Code Playgroud)
代码是:
#include <cstdlib>
#include <iostream>
using namespace std;
int getValueFromASM()
{
_asm {
mov eax, 39
}
}
int main(int argc, char** argv) {
cout << "Hello World from C++ !\n";
cout << "ASM said " << getValueFromASM() << endl;
cout << "Back in the program before close.\n";
return 0;
}
Run Code Online (Sandbox Code Playgroud)
有人能指出我如何让内联装配工作在netbeans中.
您收到编译错误,因为您使用了错误的语法.
尝试将您的getValueFromASM
方法更改为:
int getValueFromASM()
{
asm("mov $39, %eax");
}
Run Code Online (Sandbox Code Playgroud)
可以在此处找到有关GCC内联汇编的良好指南:http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
归档时间: |
|
查看次数: |
2548 次 |
最近记录: |