lkml.org 
[lkml]   [1998]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: NOP instruction
Date
From

[...]
> > LOCK
> > SEG ES
> > MOV DI,DI
> >
> > The first time I read through that, I wondered what on earth it was
> > supposed to do, and only later did I realise it was effectively a
> > rather verbose NOP instruction...
Odd choice for a NOP - the LOCK can be slow on
SMP systems, or maybe not if we aren't actually accessing memory?
>
> I've always wondered... A much used NOP "instruction" is
> OR AX,AX (or similar);
> But doesn't this, as well as MOV DI,DI, set the zero flag???
MOV doesn't set any flags, if I remember correctly. The compiler
may feel free to use "OR AX,AX" and similiar as a NOP if it knows
that the zero flag won't be needed or that it will be
set to the correct value anyway (because the instruction
before the OR AX,AX calculated a result in AX)

> As a NOP instruction is supposed to do nothing, would this then be wrong?
> (Nothing meaning not setting any flags?)
>
> Hmmm... Where's the time from the good ol' Z80 when you HAD a real NOP
> instruction? *Sigh* :-)
The x86 has a real nop instruction. The point of using other
NOP forms is that the x86 NOP is one byte, and takes a fixed
time to execute. Now, if we happen to need 6 byte of filling
then 6 NOP's take 6 times the time to execute. Putting a
single 6-byte do-nothing instruction there instead will be faster.
A good compiler will use the fastest NOP form available
for the gap to be filled. x86 instructions have sizes
varying from 1 to 15 bytes.

Helge Hafting


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [from the cache]
©2003-2011 Jasper Spaans