Re: PATCH - assembler glitches

Martin Dalecki (dalecki@cs.net.pl)
Wed, 13 Oct 1999 02:08:34 +0200


"Richard B. Johnson" wrote:
>
> On Tue, 12 Oct 1999, Martin Dalecki wrote:
>
> > The attached patch is sweepping out obvious errors in IA32 assembler
> > code.
> > Just apply it.
> >
> > --Marcin Dalecki
>
> Does the new gas 'know' when you are not yet in 32-bit protected mode
> and/or when you are? If not, you will end up with a bunch of 0x66
> prefixes which are not correct.

As far as I know this gets specifyed explicitly in the assembler code
itself. I can remember to have been reading about the defficiencies
of 16 bin asm code in gas several years ago and there it was stated.
And yes the new gas is supposed to support 16 bit code correctly.
Otherwise the gas wouldn't be able to warn wbout it. (As in fact
does in the newes binutils!)

> For instance, movl %edx, %eax in 32-bit mode is exactly the same
> code as movw %dx, %ax in 16-bit mode. If gas thinks it's in
> 32-bit mode, and you do movw %dx, %ax it will put 0x66 as a prefix.

I was just cleaning up cases which where looking like moving
a 32 bit register into a 16 bit one. The former gas versions where
making sens of those cases for themself.

> By the same token, if you truly are in 32-bit mode, and you want
> to do movw %dx, %ax, the resulting code must have a 0x66 prefix.

Yeep.

> I see in the patch, a number of instances where a movw will be
> made to a segment register. This forces an extra 0x66 prefix which
> is not necessary as longword moves to segment registers is allowed.

As far as I can see gas acnowlendges those cases.

> You need to look through the binary produced in the boot code
> before the machine enters protected mode and look for 0x66. If
> these exist as a prefix, something is wrong and, although you
> can be lucky most of the time, the result may be an unbootable
> machine.
>
> Cheers,
> Dick Johnson
> **** FILE SYSTEM WAS MODIFIED ****
> Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
> Warning : It's hard to remain at the trailing edge of technology.

--
	Marcin Dalecki

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