visual-c++assembly

How to view the assembly behind the code using Visual C++?


I was reading another question pertaining the efficiency of two lines of code, and the OP said that he looked at the assembly behind the code and both lines were identical in assembly. Digression aside, how could I view the assembly code created when a program is compiled.

I'm using Microsoft's Visual C++, but I would also like to know if it's possible to view the assembly behind code written in Visual Basic.

So, how do I view the assembly code behind a program written in higher level languages like C++ and Visual Basic?


Solution

  • There are several approaches:

    1. You can normally see assembly code while debugging C++ in Visual Studio (and Eclipse too). For this in Visual Studio put a breakpoint on code in question and when the debugger hits it, right-click and find "Go To Assembly" ( or press CTRL+ALT+D )

    2. The second approach is to generate assembly listings while compiling. For this go to project settings -> C/C++ -> Output Files -> ASM List Location and fill in file name. Also select "Assembler Output" to "Assembly With Source Code".

    3. Compile the program and use any third-party debugger. You can use OllyDbg or WinDbg for this. Also you can use IDA (interactive disassembler). But this is a hardcore way of doing it.