Re: [PATCH] Removes x86 warning messages

Alan Modra (alan@SPRI.Levels.UniSA.Edu.Au)
Fri, 29 Oct 1999 08:50:17 +0930 (CST)


On Thu, 28 Oct 1999, H. Peter Anvin wrote:

> In the case of segment register operations, the size of 16 bits is
> implicit in the opcode, so there is never any need to generate it.
> Technically you can do a movl from a 32-bit memory operand to force 32
> bits of memory to be touched; otherwise they are exactly equivalent.

True for moves *to* a segment register. There is a difference when moving
*from* a segment register.

movl %ds,%eax # Sets upper 16 bits of eax to an "implementation defined"
# value according to Intel. Actually running the insn on
# hardware proves this to be so: Later Intel cpus set the
# top 16 bits to zero, while earlier cpus trash the top
# 16 bits of eax (ie. they are buggy)
movw %ds,%ax # Doesn't touch the upper 16 bits of eax. However it
# costs you an operand size prefix, which slows execution.

>
> Therefore, the assembler should always generate the shortest form. Case
> closed.

It has done so for about a year. ie.

movl %eax,%ds
movw %ax,%ds
mov %eax,%ds
mov %ax,%ds

all generate the same opcode bytes. We can't do the same for moves from a
segment register for the reason I gave above.

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