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:

    Acknowledge your will and speak to us all, “This alone is what I will to be!” Hang your own penal code up above you: we want to be its enforcers!
    Friedrich Nietzsche (1844–1900)