Re: Do "nops" add to the latency of a program?
- From: "William J. Leary Jr." <spamtrap@xxxxxxxxxx>
- Date: Tue, 24 Oct 2006 23:26:57 -0400
"Trev" <spamtrap@xxxxxxxxxx> wrote in message
news:1161699912.543439.125810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
My compiled program has had a few nops put in the listing, and I've
noted a few places where nops could be used, eg:
push 5
pop edi
cmp eda, edi
which I can shorten to cmp eda, 5.
Saying "nop" or "nops" usually means use of the NOP instruction, op-code 90H,
wastes 3 cycles (on a 386), and modifies nothing nothing but (E)IP.
What I assume you mean is instructions which seem to, in the context you find
them, serve no purpose.
Does the inclusion of nops slow the program down? Does
the computer skip over them, or does it still "process" them,
even if they do nothing?
It doesn't do look-ahead trying to divine the ultimate purpose of the
instruction sequence. How could it know, for example, whether the side effect
of leaving 5 in EDI is important or not? Or that you didn't actually have a
reason for leaving a 5 one position below the stack? I'd expect it to execute
every instruction because they don't really "do nothing." In this case a 5 is
stored in memory, and the stack pointer moved. A 5 is read from memory into a
register and the stack pointer moved, and a comparison operation takes place.
Side effects, as compared to CMP EDA,5 are the stack pointer was changed twice,
a 5 was left in memory, and EDI was modified to contain a 5. These operations
just don't, in this case, have any value. But value is for the programmer to
decide, not the processor.
- Bill
.
- References:
- Do "nops" add to the latency of a program?
- From: Trev
- Do "nops" add to the latency of a program?
- Prev by Date: Re: Do "nops" add to the latency of a program?
- Next by Date: Re: Do "nops" add to the latency of a program?
- Previous by thread: Re: Do "nops" add to the latency of a program?
- Next by thread: Re: Do "nops" add to the latency of a program?
- Index(es):