NOP or NOOP (short for No OPeration) is an assembly language instruction, sequence of programming language statements, or computer protocol command that does nothing at all.
NOP Machine Instruction
Most computer
instruction sets include an instruction that does nothing for a specific number of clock cycles; it makes no changes to
memory or
program status. NOPs are most commonly used for timing purposes, to force memory
alignment, to prevent
hazards, to occupy a
branch delay slot, or as a "place-holder" to be replaced by active instructions later on in program development. The characteristics of the NOP instruction for the
Intel x86 CPU family are:
The Intel 8080 and Zilog Z80 use the opcode 0x00 for NOP. In the MOS Technology 6502 and its descandant processors, NOP has the opcode 0xEA. The Motorola 68000 processor's NOP instruction has the opcode 0x4E71.
The ARM processor does not have a NOP instruction, so programmers usually use a MOV instruction with the same source and destination instead.
NOOP code
NOOP can also be used as a description for what a function or sequence of programming language statements does. If the function or code has no net effect, then it could be called a noop. An example code block in the C programming language could be as follows:
{
i++;
i--;
}
Another example of a single C statement that would also produce a NOOP:
i+1;
Today, optimizing compilers search for noop statements in code. As the function or piece of code does nothing, the compiler simply removes it. Many optimizing compilers include a directive by which a programmer can explicitly disable this optimization, thereby including code that appears to be a noop to the optimizing compiler. This is useful for cases in which removing the code would cause a bug.
NOOP Protocol Commands
Many
computer protocols, such as
telnet, include a NOOP command that a client can issue to request a response from the server without requesting any other actions. Such a command can be used to ensure the connection is still alive or that the server is responsive. A NOOP command is part of the following protocols (
this is a partial list):
Note that unlike the other protocols listed, the IMAP4 NOOP command has a specific purpose which is to allow the client to request that the server send unsolicited information reflecting the actions of other clients.
While most telnet servers respond to a NOOP command with "OK" or "+OK", some programmers have added quirky responses to noop. Some examples:
noop : OK, but why? :)
noop : Well, noop to you too!
Computing acronyms | Assemblers
NOP