[ASM]Nop is good for...?

Thread Starter


Joined May 3, 2007

I began to study MicroProcessors (Assembly 8086)
and yesterday I heard about the "nop" command.
From what I UNDERSTOOD this command target is to "waste"
time, to create a sort of "delay".

I also heard that some people use it as a note to themselves to
write commands in the future.

But you allways can write "notes" ( ; need to put here bla bla bla )
So What is the main and real target of the "nop" command?

Does Intel has docs about the commands and their targets?

Thanks in advance,


Joined Jan 28, 2005
NOP or "No Operation" is most often used to introduce a machine-cycle delay in the code. This can be handy when you are need to introduce a slight delay between two related events such as changing an output to a slow peripheral followed by an input of the results from that same peripheral.

There are other uses that don't immediately leap to mind.



Joined Nov 17, 2003
So What is the main and real target of the "nop" command?
Since the nop command is essentially an instruction that does nothing but waste processor cycles, it should be no surprise that its most useful purpose is in the form of processing timing management. The most obvious example is prevention of hazards - a process where dependant instructions in the processor pipeline become out of sequence. It is also useful for forcing data allignment in the computers memory.



Joined Jan 26, 2008
It's also useful for debugging on some hardware. It's possible to 'remove' an instruction from a running program in a debugger by overwriting the instruction with NOPs.



Joined Feb 24, 2006
It sometimes falls out of an orthogonal instruction set for free because one possible implementation is to move a register into itself without modification of condition codes. Another possible NOP is a Branch Always to the next instruction. It's not like processor designers have to strain very hard to create instructions which do nothing.