Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate assembly code from C++ source in Visual Studio 2010

I want to generate assembly code from C++ source code using Microsoft VC++ Compiler. I want to do this in the command line itself. Not from the IDE.

What're the commands/options?

like image 536
Nawaz Avatar asked Dec 21 '10 12:12

Nawaz


People also ask

How do I get assembly code from C in Visual Studio?

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".

Can you write assembly in Visual Studio?

Since Visual Studio does not recognize assembly code, Visual Studio will have to be told what program to call to compile the assembly code. In this section, we'll cover the basic steps of creating a project, adding assembly code to it, specifying the Custom Build instructions, and building the project.

Does GCC generate assembly?

With the gcc compiler, you can obtain a listing of the assembly language generated by the compiler by using the -s option. For example, "gcc -c -S filename. c" will produce the assembly language code on file filename.


2 Answers

I believe this is what the /FA switch is for.

like image 153
Oswald Avatar answered Oct 28 '22 13:10

Oswald


in http://msdn.microsoft.com/en-us/library/367y26c6.aspx

You can use "/FA /Fa" options you can use..

In there documents,

CL /FAcs HELLO.CPP

/FA    Assembly code; .asm
/FAc   Machine and assembly code; .cod
/FAs   Source and assembly code; .asm
       If /FAcs is specified, the file extension will be .cod
/FAu   Causes the output file to be created in UTF-8 format, 
       with a byte order marker. 
       By default, the file encoding is ANSI, 
       but use /FAu if you want a listing file that displays correctly on any system, 
       or if you are using Unicode source code files as input to the compiler.
       If /FAsu is specified, and if a source code file uses Unicode encoding other than UTF-8, 
       then the code lines in the .asm file may not display correctly.
like image 35
cpplover - Slw Essencial Avatar answered Oct 28 '22 12:10

cpplover - Slw Essencial