RollRoll
RollRoll

Reputation: 8472

How to see the assembly code from a Ansi C hello world written in Visual Studio?

I'm playing with Ansi C in visual studio, created the simple Ansi C program (I had to change VS configuration to not use cpp but ansi c)

int a = 0;
int b = 0;

printf("Hello World! \n\n");

system("PAUSE");
return 0;

I compiled it and it generated this:

enter image description here

First of all I was expecting a simple .exe and I don't know why this .ilk and .pdb were created but the question here is how can I see the assembly code generated by the compiled c program?

thanks

Upvotes: 1

Views: 97

Answers (2)

librik
librik

Reputation: 3788

Use the Assembler Output setting in the Project Properties.

You can request that Visual Studio show the assembly code for your compiled program by:

  1. Right-clicking on the Project name in the Solution Explorer, and choosing Properties from the menu that appears.
  2. Using the tree-view menu on the left side of the dialog box that appears, click to Configuration Properties > C/C++ > Output Files.
  3. Change the value for Assembler Output from No Listing to Assembly with Source Code (/FAs)
  4. Click OK to close the dialog box.
  5. Rebuild your program.

Now you will have a project-name.asm file, located in the Debug or Release subdirectory of your project directory. That is a text file displaying the source code of your program, and the assembly code that each line was converted into.

Upvotes: 0

Jerry Coffin
Jerry Coffin

Reputation: 490693

The .ilk is an incremental linking file, which can help speed up linking when you make minor changes to your code, then re-link.

The .pdb is a Program database--use when debugging.

To get the assembly language to which your code translates, you can compile with /Fa.

Upvotes: 3

Related Questions