Subject: Re: questions about various .S files in i386/boot
To: None <perry@piermont.com>
From: Matt Beal <beal@umiacs.UMD.EDU>
List: port-i386
Date: 03/20/1996 20:43:09
> I've been scampering around some more in i386/boot of late, and I
> discovered that there are lots of things in there that I simply do not
> understand at all.
> 
> For instance, take the enclosed snippet of code, from start.S. All
> through the code, we find these data32 macros. Could someone please
> explain to me what they mean and why they are there? I feel sort of
> stupid, but I just "don't get it" I suppose. Does it have something to
> do with 16 bit vs. 32 bit *86 code?
> 
> [...]
> #define	addr32	.byte 0x67
> #define	data32	.byte 0x66
> [...]
> data32
> movl	$BOOTSEG, %eax

Exactly (16- vs 32-bit). On the x86's, when opcode 0x66 preceeds an
instruction, such as the one above, it tells the CPU to use 16-bit
accesses in 32-bit mode, and vice versa. In x86 instruction encodings,
16- and 32-bit instructions look exactly the same, and depend on which
mode (16- or 32-bit) the CPU is in. To change to the meaning of the
instruction, from a 16-bit access to a 32-bit one, you prefix that opcode.
In the case of the initial boot code, which runs in 16-bit mode, the opcode
is required for 32-bit register accesses.

matt