Segregs are an exception to the "movl xx, %ax" rule, for the reasons
explained below by Alan Modra:
================================== 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.
By old binutils, I mean anything before April 1998 in the Cygnus tree, or earlier than 18.104.22.168 from H.J. Lu---
So, someday (I planned on 2.5 land) everyone will be using a reasonably recent binutils and we'll be able to fix them up properly. It's scary to see how many people are still using older versions. And it's simply because there is no real "pressing" reason to update, just a lot of little ones like this that us developers want :)
Chris Noe (firstname.lastname@example.org)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to email@example.com Please read the FAQ at http://www.tux.org/lkml/