I have this c++ code:
#include <iostream>
using namespace std;
int main () {
char chr[] = "111111111111";
int pop = 9999;
cout << chr << (pop+1) << endl;
}
when I do in the shell (64 bit linux) g++ -S hello.cpp I get assembly code :
when I use on it nasm hello.s it says it contains a lot of errors such as:
instruction needed
expression syntax error
symbol `popq' redefined
maybe it is because it is 64bit? how can I compile the .s I created with the g++?
The assembler generated by GCC is using what is known as AT&T syntax, which differs from the Intel-syntax used by nasm. You have to use the GCC assembler (
as) to compile GCC generated assembler files.See e.g. http://en.wikipedia.org/wiki/GNU_Assembler#Criticism.
For more information about the GNU assembler syntax, see http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax.