-S option to gcc (or g++).
gcc -S helloworld.c
This will run the preprocessor (cpp) over helloworld.c, perform the initial compilation and then stop before the assembler is run.
By default this will output a file
helloworld.s. The output file can be still be set by using the
gcc -S -o my_asm_output.s helloworld.c
Of course this only works if you have the original source. An alternative if you only have the resultant object file is to use
objdump, by setting the
--disassemble option (or
-d for the abbreviated form).
objdump -S --disassemble helloworld > helloworld.dump
This option works best if debugging option is enabled for the object file (
-g at compilation time) and the file hasn’t been stripped.
file helloworld will give you some indication as to the level of detail that you will get by using objdump.