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:

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)