NOP
In computer science 'NOP' or 'NOOP' (short for '''N'o 'OP'eration'') is an assembly language instruction, sequence of programming language statements, or computer protocol command that does nothing at all (besides wasting cpu clock cycles).
| Contents |
| NOP machine instruction |
| NOP code |
| NOP protocol commands |
| Cracking |
| See also |
| References |
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).
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 (or to replace removed instructions when re-factoring would be problematic or time-consuming).
The characteristics of the NOP instruction for the Intel x86 CPU family are:
★ Mnemonic:
NOP★ Clock cycles: 3
★ Bytes: 1
★ Opcode: 0x90 [1]
NOP code
NOP is sometimes used as a description for the action performed by a function a sequence of programming language statements. If the function or code has no effect, then it is sometimes called a NOP or NOOP (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'' (just a semi-colon and no, a compiler not required to generate a nop instruction)
;
The null statement is useless by itself, but can have a syntactic use in a wider context, e.g., within the context of a loop:
while (ReadChar() != '
') ;
The above code continues calling the function ''ReadChar'' until it returns a
(newline) character.
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''):
★ telnet
★ FTP
★ SMTP
★ X11
★ POP3
★ NNTP
★ finger
★ IMAP4
Note that unlike the other protocols listed, the IMAP4 NOP 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!
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 such that, rather than completing their assigned task(s), they simply return a Boolean value of "true" or "false" (or whichever other parameter was being checked for).
A pseudocode example of such usage is as follows. The original unmodified subroutine:
on checkForSerialNumber(theSerialNumber)
set serialNumberValidity to false
if theSerialNumber is in {abc123, def456, ghi789} then
set serialNumberValidity to true
else
display dialog {"The serial number was not valid."}
alertAuthoritiesToPiracy
end if
return serialNumberValidity
end checkForSerialNumber
The modified subroutine, where statements marked with "
#" have been replaced with NOP instructions:on checkForSerialNumber(theSerialNumber)
#set serialNumberValidity to false
#if theSerialNumber is in {abc123, def456, ghi789} then
set serialNumberValidity to true
#else
# display dialog {"The serial number was not valid."}
# alertAuthoritiesToPiracy
#end if
return serialNumberValidity
end checkForSerialNumber
The raw, uncompiled source code of commercial applications is not typically made available to the general public. Because of this, reverse engineering with various software tools is typically necessary in order to determine the actual hexadecimal bytes that must be edited in the final, compiled code, so as to insert the appropriate NOP(s) where necessary.
See also
★ Computer architecture
★ HLT
★ Instruction set
★ x86
References
1. Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual
This article provided by Wikipedia. To edit the contents of this article, click here for original source.
psst.. try this: add to faves

العربية
中国
Français
Deutsch
Ελληνική
हिन्दी
Italiano
日本語
Português
Русский
Español



