0x9*_*x90 2 c++ linux assembly nasm
我有这个c ++代码:
#include <iostream>
using namespace std;
int main () {
char chr[] = "111111111111";
int pop = 9999;
cout << chr << (pop+1) << endl;
}
Run Code Online (Sandbox Code Playgroud)
当我在shell(64位Linux)中执行g++ -S hello.cpp汇编代码时:
当我使用它时,nasm hello.s它说它包含很多错误,例如:
instruction needed
expression syntax error
symbol `popq' redefined
Run Code Online (Sandbox Code Playgroud)
也许是因为它是64位?如何编译我用g ++创建的.s?
GCC生成的汇编程序使用的是所谓的AT&T语法,它与nasm使用的Intel语法不同.您必须使用GCC汇编程序(as)来编译GCC生成的汇编程序文件.
参见例如http://en.wikipedia.org/wiki/GNU_Assembler#Criticism.
有关GNU汇编语法的更多信息,请参阅http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax.