user466534
user466534

Reputation:

Convert C++ program into assembly

I am using Visual Studio 2010 and suppose I have to write some program. Can I make it such that Visual Studio shows me this code translated into assembly language?

And if yes how do I do it? For example, I have a factorial program:

int fact(int n) {
    if (n<=1)  
        return 1;
    return n*fact(n-1);
  }

Upvotes: 5

Views: 20323

Answers (2)

celavek
celavek

Reputation: 5705

Put a breakpoint into your factorial function, start debugging, go to Call Stack window, right click on your function, select Go To Disassembly

Upvotes: 4

Stephen
Stephen

Reputation: 6087

See the answers to this question:

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 debugger hits it rigth click and find "Go To Assembly" ( or press CTRL+ALT+D )
  2. 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 "Assembly 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 hardcore way of doing it.

Upvotes: 9

Related Questions