Re: NOP instruction

Riley Williams (rhw@bigfoot.com)
Tue, 15 Dec 1998 11:45:12 +0000 (GMT)


Hi there.

>>> BTW, they're not nop instructions these days: they're the largest
>>> filler instructions gas can put in, so an alignment of a few bytes
>>> needn't take any longer to execute than a single byte alignment.

>> I remember seeing some assembly that had the following sequence in
>> the middle thereof (not for gcc but you can probably decode it):

>> 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...

> 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???

I don't think MOV sets any flags, but OR certainly does, as do all of
the arithmetic/logical instructions...

> As a NOP instruction is supposed to do nothing, would this then be
> wrong? (Nothing meaning not setting any flags?)

Not necessarily - it depends whether the program uses the flags just
after the instruction in question - but it would have to be taken into
account.

> Hmmm... Where's the time from the good ol' Z80 when you HAD a real
> NOP instruction? *Sigh* :-)

There IS a designated NOP instruction on the 80x86 family. However, as
with all processors I've come across, it's just an ordinary opcode
that happens to result in nothing being done.

>From memory (and without references handy), here's the translation of
the official NOP opcode on various processors into English:

6502 Jump to address in register PC.
8080/Z80 Move the contents of register DE into register DE.
SC/MP Wait for register PC to become non-zero.

In the case of the SC/MP processor, the "halt" instruction corresponds
to the instruction "Wait for register PC to become zero", and if they
happen to be stored in the highest location in the memory map, they
swap roles...

I could be wrong in each case, my memory isnae perfect, but the
decoding of the opcodes along those (very different) lines is real.

Best wishes from Riley.

-
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/