lkml.org 
[lkml]   [1999]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Compiler/Assembler warnings <patch>
On Wed, 15 Dec 1999, Richard B. Johnson wrote:
[...]
> GAS is not lying. The code I fixed for the second time was broken.
> There is no way that a "movl something, %ax" should ever even assemble.
> | |____ short register
> |__________________ long operand.
>
> And if you were told that warnings of this kind are preferable, preferable
> to whom?
[...]

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 2.9.0.3 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
(stiker@northlink.com)





-
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:55    [W:0.049 / U:1.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site