Generate Assembly From C++ Code in Visual Studio
Sometimes we want to see the assembly code generated from a piece of C++ code. It could be very helpful for:
- Better understanding about how compiler optimize our code
- Better understanding about the dark side of the programming language that we are using to avoid the pitfalls.
- Finding performance hints.
- Debugging really tricky defects.
And I found that I am not the only person have this wish:
So I think the only question left is: how to generate assembly from our C++ source code? You can of course use a debugger to disassembly the binary file but apparently that is not an efficient way.
There is actually an option in Visual C++. Right click the cpp file and select ‘Properties’. In the property pages set Configuration Properties –> C/C++ –> Output Files –> Assembler Output to “Assembly With Source Code (/FAs)”:
After build your project you should be able to find the *.asm file generated under $(IntDir), as set in “ASM List Location” property.
You can make the similar change in your project property page. I would not recommend to do this as that will generate assembly for all cpp files in your project, which is not necessary in most cases, and will greatly slow down your compile speed.
Internally change the property just enable the /FAs switch for cl.exe. You can take a look at MSDN for more detailed information.
October 3rd, 2008 at 1:25 pm
[...] « Generate Assembly From C++ Code in Visual Studio [...]
December 19th, 2009 at 9:21 am
Good morning
I loose control!
Free java casino no download
casino
List flash no download casino
casino
Virtual casino birthday welcome bonus
casino
Flash no download casino without deposit
casino
Internet poker web sites