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

H. J. Lu (hjl@freya.yggdrasil.com)
Wed, 25 Mar 1998 12:13:48 -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.

I see.

>
> 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 (*).

My P II manual downloaded from www.intel.com is quite clear on moving
data between a segment register and a general purpose register. It
has one paragraph with examples like "MOV DS, AX" and "MOV DS, EAX"
in Intel syntax.

>
> (*) 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

The current gas emits "8c d8". Why is that slower?

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

The current gas defaults to 16-bit and rejects movl. I can make it to
accept "movl". I don't see it should default to 32-bit.

BTW, the current gas is 2.8.1.0.25.

-- 
H.J. Lu (hjl@gnu.ai.mit.edu)

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