If you are building the program yourself, you can ask your compiler to emit assembly source. For most UNIX compilers use the -S switch.
If you are using the GNU assembler, compiling with -g -Wa,-alh will give intermixed source and assembly on stdout (-Wa asks compiler driver to pass options to assembler, -al turns on assembly listing, and -ah adds "high-level source" listing):
g++-g -c -Wa,-alh foo.cc
For Visual Studio, use /FAsc.
If you have compiled binary, use objdump -d a.out on UNIX (also works for cygwin), dumpbin /DISASM foo.exe on Windows.
Debuggers could also show disassebly. Use disas command in GDB, or the disassembly window of Visual Studio on Windows.
Approach 2 Whatever debugger you're using should have an assembly view (VS, Borland IDE, gdb, etc). If you are not using a debugger and you merely want to see what assembly is in a program you can use a disassembler or alternatively, run the program and attach to it with a debugger and do the dump from there. See references to disassemblers for info on options. Approach 3
As someone else mentioned, your platform's debugger is a good starting point. For the jackhammer of all debuggers and disassemblers, take a look at IDA Pro.
On Unix/Linux platforms (including Cygwin) you can use objdump --disassemble .
If there is an option to have the compiler generate the assembler (like gcc -S, or the VS /FA option below), that is preferable over disassembly. It is more symbolic.
Sure, if you have the source.
By the way, you'd be surprised how much symbol information can be deduced by IDA Pro.
In Visual Studio;
set a breakpoint
run the program until it stops at the breakpoint
rightclick on the sourcecode and pick "show dissasembly"
In GCC/G++, compile with -S. That will output a something.s file with the assembly code.
Edit: If you want the output to be in Intel syntax (which is IMO, much more readable, and most assembly tutorials use it), compile with -masm=intel.
add also -fverbose-asm option
Most compilers have an option to output an assembly listing. E.g. with VisualStudio you can use something like:
cl.exe /FAfile.asm file.c
For best readability though, most debuggers will offer a view that interleaves the disassembly with the original source, so you can compare your code with the compiler's output line by line.
Lots of people already told how to emit assembly code with a given compiler. Another solution is to compile an object file and dump it with a tool such objdump, readelf (on Unix) or DUMPBIN(link) (on Windows). You can also dump an executable, but it will be more difficult to read the output.
This has the advantage of working the same way with any compiler.