Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / March 2006

Tip: Looking for answers? Try searching our database.

Why does compiler emit NOP instructions?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Rilling - 05 Mar 2006 06:11 GMT
Hi.

Not too long I had to use Reflection.Emit to dynamically generate some
classes that were only to be dynamically generated based on runtime
conditions.

Before emitting the op codes, I created a class and compiled it, then
reviewed the op codes using Reflector.

Well, I noticed the compiler created, in some cases, a sequence of NOP
instructions.  Why?  Is there a reason that the compiler felt it necessary
to emit these?  Are there timing sequences that requires NOP to exist?
Homer J Simpson - 05 Mar 2006 06:58 GMT
> Hi.
>
[quoted text clipped - 8 lines]
> instructions.  Why?  Is there a reason that the compiler felt it necessary
> to emit these?  Are there timing sequences that requires NOP to exist?

It's not unknown for compilers. Sometimes after optimisation the compiler
replaces unneeded codes with NOPs - perhaps a jump only needs 3 bytes
instead of 4. It's easier to replace the opcode than to reassemble the whole
thing.

As for timing, it's possible but unlikely. That's the sort of thing you do
in hand assembly only.
Christoph Nahr - 05 Mar 2006 07:38 GMT
>Well, I noticed the compiler created, in some cases, a sequence of NOP
>instructions.  Why?  Is there a reason that the compiler felt it necessary
>to emit these?  Are there timing sequences that requires NOP to exist?

Timing doesn't figure into IL code.  The NOPs are there to facilitate
debugging -- they allow setting breakpoints on "non-statements" such
as the entry of a loop, and adding code during edit & continue.  They
won't appear when you turn on optimization.
Signature

http://www.kynosarges.de


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.