NOP

NOP

In computer science, NOP or NOOP (short for No Operation or No Operation Performed) is an assembly language instruction, sequence of programming language statements, or computer protocol command that effectively does nothing at all.

Contents

NOP machine instruction

Some computer instruction sets include an instruction whose explicit purpose is not to change the state of any of the programmer accessible registers, status flags, or memory and which may require a specific number of clock cycles to execute. In other instruction sets, a NOP has to be simulated by executing an instruction having operands that cause the same effect (e.g., on the SPARC processor, the instruction sethi 0, %g0 is the recommended solution).

A NOP is 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 (or to replace removed instructions when refactoring would be problematic or time-consuming). In some cases, a NOP can have minor side effects; for example, on the Motorola 68000 series of processors, the NOP opcode will cause a synchronization of the pipeline.[1]

Here are the characteristics of the NOP instruction for some CPU architectures:

CPU architecture Mnemonic Bytes Opcode Notes
Intel x86 CPU family NOP 1; 1–9 for i686 0x90; 0x0f 0x1f [2] The NOP instruction on the x86 CPU family is actually XCHG EAX, EAX (resulting the same opcode 0x90) - the instruction without any effect.
Intel 8051 / MCS-51 family NOP 1 0x00
ARM NOP 4 0x00000000 This stands for andeq r0, r0, r0 which has no effect at all. The assembly instruction nop will most likely expand to mov r0, r0 witch is encoded 0x01A00000.[3]
MIPS NOP 4 0x00000000
MMIX SWYM 4 0xfd****** SWYM stands for “Sympathize with your machinery.” The * digits can be chosen arbitrarily.
Motorola 68000 family NOP 2 0x4e71
MOS Technology 65xx NOP 1 0xea NOP consumes two clock cycles.  Undefined opcodes in the NMOS versions of the 65xx family were converted to be NOPs of varying instruction lengths and cycle times in the 65C02.
PowerPC NOP 4 0x60000000 (extended opcode for ori r0,r0,0)
PIC microcontroller NOP 12 bits 0b000000000000
SPARC NOP 4 0x01000000
Z80 NOP 1 0x00

From a hardware design point of view, unmapped areas of a bus are often designed to return zeroes; since the NOP slide behavior is often desirable, it gives a bias to coding it with the all-zeroes opcode.

NOP code

NOP is sometimes used as a description for the action performed by a function or a sequence of programming language statements if the function or code has no effect (it might also be called redundant code). A common compiler optimization is the detection and removal of this kind of code.

The following is an example of a single C statement that behaves like a NOP (the issue is whether the statement affects program output, not whether or not a compiler generates any code for this statement):

    i+1;

(This statement performs an addition and discards the result.)

The simplest possible statement in C that behaves like a NOP is the so called null statement, which is just a semi-colon in a context requiring a statement. (A compiler is not required to generate a NOP instruction in this case; typically, no instructions whatsoever would be generated.)

  ;

The null statement is useless by itself, but it can have a syntactic use in a wider context, e.g., within the context of a loop:

  while (ReadChar() != '\n')
     ;

The above code continues calling the function ReadChar until it returns a \n (newline) character.

The Python programming language has a pass statement which has no effect when executed and thus serves as a NOP. It is primarily used to ensure correct syntax due to Python's indentation-sensitive syntax; for example the syntax for definition of a class requires an indented block with the class logic, which has to be expressed as pass when it should be empty.

NOP protocol commands

Many computer protocols, such as telnet, include a NOP 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 - it allows the server to send any pending notifications to the client.

While most telnet or FTP servers respond to a NOOP command with "OK" or "+OK", some programmers have added quirky responses to the client. For example, the ftpd daemon of MINIX responds to NOOP with the message:[4]

200 NOOP to you too!

Cracking

NOPs are often involved when cracking software that checks for serial numbers, specific hardware or software requirements, presence or absence of hardware dongles, etc. This is accomplished by altering functions and subroutines to bypass security checks and instead simply return the expected value being checked for. Because most of the instructions in the security check routine will be unused, these would be replaced with NOPs.

Security exploits

The NOP opcode can be used to form a NOP slide, which allows code to execute when the exact value of the instruction pointer is indeterminate (e.g., when a buffer overflow causes a function's return address on the stack to be overwritten).

See also

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • NOP — NOP, mnémonique pour No Operation (en français : « aucune opération »), est une instruction pour les processeurs de la famille x86. Sommaire 1 Description 1.1 Drapeaux affectés 1.2 Excepti …   Wikipédia en Français

  • NOP —   [Abk. für No Operation, dt. »keine Anweisung«], ein Maschinenbefehl, der lediglich Rechenzeit verbraucht, aber da keine Aktionen ausgeführt werden keine Auswirkung hat. Man verwendet NOPs, um Verzögerungsschleifen zu programmieren …   Universal-Lexikon

  • nop — ac·ti·nop·o·da; ac·ti·nop·te·ran; ac·ti·nop·te·ri; ac·ti·nop·te·ryg·ii; ad·e·nop·a·thy; am·i·nop·ter·in; bal·ae·nop·tera; bal·ae·nop·ter·i·dae; cas·ta·nop·sis; coe·nop·ter·i·da·les; co·nop·i·dae; di·go·nop·o·rous; ech·i·nop·a·nax; ech·i·nop·sine; …   English syllables

  • NOP — У этого термина существуют и другие значения, см. NOP (значения). В информатике NOP или NOOP (сокращение от английского: «No OPeration») инструкция процессора на языке ассемблера, или команда протокола, которая предписывает ничего не делать. NOP… …   Википедия

  • NOP — Die Abkürzung NOP steht für: National Organic Program – ein Zertifizierungsprogramm für Lebensmittel, siehe auch Verordnung (EG) Nr. 834/2007 (Öko Verordnung) No Operation (englisch für „Nulloperation“) – ein spezieller Befehl für Prozessoren und …   Deutsch Wikipedia

  • Nop — Los nop son un grupo mon jemer de unos pocos miles de individuos, que habitan en el Vietnam meridional. A menudo son clasificados etnográficamente junto con los lat, laya y otras minorías étnicas. Categoría: Etnias de Vietnam …   Wikipedia Español

  • nop — ● ►en /nop/ sg. ►PROG No Operation. Pas d opération, instruction assembleur indiquant au processeur qu il ne doit rien faire. Cela peut paraître idiot et inutile, mais c est très pratique pour réaliser une temporisation très fine, par exemple …   Dictionnaire d'informatique francophone

  • Nop Bophann — (died 1959) was a Cambodian newspaper editor. He had been one of the representatives of the United Issarak Front in the Viet Minh side of the Joint Commission for the Implementation of the Geneva Accords.[1] In May 1956, Nop Bophann, along with… …   Wikipedia

  • NOP (значения) — NOP может означать: NOP  от англ. «No OPeration»  инструкция, которая предписывает ничего не делать. Гаплогруппа NOP  одна из гаплогрупп в генетической генеалогии …   Википедия

  • nop-bed — see nop …   Useful english dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”