NOP - NOP Code

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.

Read more about this topic:  NOP

Famous quotes containing the word code:

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)