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.

.netcsharpassemblywindows
Posted by: Dinesh Singh Malik, Last edit by: Dinesh S Malik
Last revised: 09 Jun, 2019 10:16 PM History

Comments

No comments yet. Be the first!

Your Comments

Comment unsuccessful. Please correct the errors below.
Used for your gravatar. Not required. Will not be public.
Posting code? Indent it by four spaces to make it look nice. Learn more about Markdown.

Preview