Short comparision of Assembly created in Debug and Release mode.

Comment unsuccessful. Please correct the errors below.

Debug vs Release Mode and the NOP Instruction

Ok! After a long rest, I am back again. I have been reading a lot and so it's time to talk about some them. In the recent past, I found that many developers (including me) will complain about the presence of the so called mysterious "NOP" instruction in the .NET assembly code. The other day I tried to have a look into this and found that "NOP" instruction is an instruction related to the debuggers. How to justify the same. So I created a simple program and compiled the code in both Debug and Release modes in Visual Studio. The Simple code I used for the demonstation using a Windows Console Application looks like :

Simple Code Snippet

Now I have two version of the output of the Program. If we take a look at the assemblies in ILDASM.
(To open ILDASM : Start(Windows key) -> All Programs -> Microsoft Visual Studio 2010 -> Microsoft Windows SDK Tools -> IL Disassembler)

Comparing Files in ILDASM

Double click the main method and have a look at the IL code emitted by the compiler. When you compare both the Debug and release version of the files, you will find the NOP instructions in the Debug version of the executable.

Comparing the IL Codes

So here you saw the slight difference in the assembly instructions for Debug and Release mode of an .NET executable/assembly.

Posted by: Dinesh Singh Malik
Last revised: 22 Aug, 2012 08:58 PM History


No comments yet. Be the first!

No new comments are allowed on this post.