Re: linux-2.2.11-pre7: i386 asm cleanup

Alan Modra (alan@SPRI.Levels.UniSA.Edu.Au)
Tue, 10 Aug 1999 18:32:03 +0930 (CST)


On Mon, 9 Aug 1999, Alan Cox wrote:

> > - AFAIU, there is no point in using just the lower half of a register to
> > fill in a segment register, with a movl to boot.
>
> I seem to remember there was. This came up before if I remember rightly
> and Linus had a specific reason for it. Check with Linus.

Compatibility with old binutils.

For example, when transferring %eax to %ds:

`movl %eax,%ds' is the "correct" instruction, but this fails to assemble
on old binutils.

`movw %ax,%ds' is also correct, but will generate an operand size prefix
on older binutils. You don't want extra prefixes if you can help it.

`movl %ax,%ds' gets a warning on new binutils, but assembles correctly on
both old and new binutils. ie. without a prefix. This is the form that
should be used despite the warning.

Note: When transferring the other way, `movw %ds,%ax' and `movl %ds,%eax'
actually do different things. The first form leaves the upper 16 bits of
%eax unchanged (and costs you an operand size prefix), while the second
form sets the top 16 bits of %eax to "an implementation defined value"
according to Intel. If you don't care about the top 16 bits of %eax, use
`movl %ds,%ax'. Again, note the missing `e' for compatibility with old
binutils.

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