Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Visual Studio: View and Step Through Assembly Code

📅 2011-Oct-12 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive


All C++ compilers (including Visual C++) can be requested to produce the assembly code generated from the C++ source code. I find it much more useful to be able to view the assembly code annotated with the original C++ code and to be able to step through the assembly code when necessary. Not only is this useful for debugging pesky bugs, but can be both entertaining and educational if you are curious about the instructions your processor is actually executing.

In Visual Studio it is easy to view the assembly code and step through it with the debugger. Just place a breakpoint in the C++ code and run the program in Debug mode. When the debugger stops at the breakpoint switch to the assembly mode by choosing Debug → Windows → Disassembly. The assembly code corresponding to your source file is displayed, beautifully annotated with the corresponding C++ source statements. You can step through the assembly code instruction-by-instruction using the debugger to your heart's content!

Tried with: Visual Studio 2010 (This feature seems to be missing in Visual C++ 2010 Express)