Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio C++: Seeing the ASM code?

I'd like to see all the asm produced by Visual Studio C++ to learn a bit about ASM, compilers, etc. I know with GCC, you can do it with the -S argument, but not in VS. How do I go about doing this?

like image 373
cam Avatar asked May 20 '10 20:05

cam


People also ask

How do I find the assembly code in Visual Studio C?

For this go to project settings -> C/C++ -> Output Files -> ASM List Location and fill in file name. Also select "Assembly Output" to "Assembly With Source Code". Compile the program and use any third-party debugger. You can use OllyDbg or WinDbg for this.

How do I open asm file in Visual Studio code?

Double-click the file named main. asm to open it in the editing window. (Visual Studio users may see a popup dialog asking for the encoding method used in the asm file. just click the OK button to continue.)

What is __ asm __ in C?

The __asm keyword invokes the inline assembler and can appear wherever a C or C++ statement is legal. It cannot appear by itself. It must be followed by an assembly instruction, a group of instructions enclosed in braces, or, at the very least, an empty pair of braces.

How do I compile asm code in Visual Studio?

Right-click Project, Build customizations, tick "masm". Right-click the . asm file, Properties, change Item Type to "Microsoft Macro Assembler".


1 Answers

The easiest way to do this is to start your program in the integrated debugger, then turn on the assembly language view. This shows the assembly language interleaved with your original source code.

Back when I used VS, this was Alt+F7 or something but it's probably changed. The advantage of doing this (over using -S equivalent) is you can focus on exactly which line(s) of code you're interested in.

like image 166
Greg Hewgill Avatar answered Oct 12 '22 05:10

Greg Hewgill