Re: [PATCH] APM support doesn't compile with binutils 2.8.1.0.24

Linus Torvalds (torvalds@transmeta.com)
Wed, 25 Mar 1998 11:56:47 -0800 (PST)


On Wed, 25 Mar 1998, H. J. Lu wrote:
>
> I double checked my Intel reference manual. As I understand,
> cs/ds/es/fs/gs/ss are all 16-bit registers. The old gas is wrong.
> There are no valid opcodes for pushl/popl. It will only cause
> confusion since pushl/popl mean change esp by 4 bytes.

But that is what it is _supposed_ to do. "pushl" _will_ change %esp by 4
bytes. The fact that %ds is a 16-bit register is immaterial.

The fact is that the intel manuals are not very clear on the issue (at
least the PPro manual I have in front of me), but that the CPU's actually
have well-defined behaviour that people depend on. So you can't just go by
the manual, because the manual is often lacking in detail and somethins
downright buggy (*).

(*) The exact details of what happens with some of the complex
instructions with faults is different in different manuals.

> As for mov, I will see if I can make "movl/mov %ds,eax" to work.
> In the meantime, "mov/movw %ds,%ax" is more accurate.

It is NOT "more accurate". They are two completely different instructions,
as you'd see if you'd actually test them.

> In
> "movl/mov %ds,eax", the 2 high order bytes may be undefined,
> depending on CPU.

Even so, behaviour is decidedly different between

movw %ds,%ax

and

movl %ds,%eax

and the latter is smaller and faster. Gas should support (and default to)
the latter because of it being smaller and faster, but gas _has_ to
support the first version too because the first version is also something
that people actually might want to use (imagine not wanting to trash the
high 16 bits of %eax).

In short, gas should always default to the 32-bit version when not told
otherwise with a "w", but should honour the "w" when it exists (and if it
accepts a "w" then it should also accept an "l" in order to be symmetric).

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu