[comp.windows.ms.programmer] 386 Enhanced Question

jason@media-lab.MEDIA.MIT.EDU (Jason A. Kinchen) (12/21/90)

Here's a more general question related to my other question about huge
pointers and Globally Allocating (sic) memory.

When the documentation says that you have a 4 Gig address space in 386
Enhanced mode, how's it doing that?  The MS C compiler is only making
16 bit code and not using the 32 bit segment registers on the 386, so
what gives?  I guess the Windows Global heap might be using a 32 bit
register, but how's it getting a 32 bit pointer back into the MS C
compiled application?

Thanks in advance,

-- 
Jason Kinchen
jason@media-lab.MIT.EDU

mojo@netcom.UUCP (Morris Jones) (12/21/90)

jason@media-lab.MEDIA.MIT.EDU (Jason A. Kinchen) writes:
>When the documentation says that you have a 4 Gig address space in 386
>Enhanced mode, how's it doing that?  The MS C compiler is only making
>16 bit code and not using the 32 bit segment registers on the 386, so
>what gives?  I guess the Windows Global heap might be using a 32 bit
>register, but how's it getting a 32 bit pointer back into the MS C
>compiled application?

Yes the MS C compiler is making 16-bit code.  Windows all runs in 16-bit
code segments.  But each of those segments can be up to 64K in size, and
you can have LOTS of them.  So you can actually use 4 Gig of address space.

Remember that on the 386 you don't have a segment number, you have a Selector
(or Descriptor).  This number is not a memory reference, but an index
into a table which describes the physical memory address being used.  Thus
a 16:16 pointer can refer to any address in the physical (or virtual)
address space.  You can use all of memory with 16:16 pointers in
selector:offset form.

Mojo

-- 
mojo@netcom.UUCP          Site Coordinating Instructor, San Jose South
Morris "Mojo" Jones       Skilled Motorcycling And Rider Training (S.M.A.R.T.)
Campbell, CA              800-675-5559 ... 800-CC-RIDER ...  408-423-2212
AA4KB @ N6LDL.#NOCAL.CA.USA.NA / aa4kb.ampr.org / netcom!mojo@apple.com

arybicki@dhw68k.cts.com (Adam Rybicki) (12/22/90)

>But each of those segments can be up to 64K in size, and
>you can have LOTS of them.  So you can actually use 4 Gig of address space.

Actually, you cannot have LOTS.  The 80386 can have up tp 8192 global selectors.
Windows itself uses about half of those, so if you have 4096 selectors
that reference a 64K block each, you end up with 262,144K.  That's a lot
of addressable space for a PC, but still quite far from 4 Gig. 


>
>mojo@netcom.UUCP          Site Coordinating Instructor, San Jose South
>Morris "Mojo" Jones       Skilled Motorcycling And Rider Training (S.M.A.R.T.)
>Campbell, CA              800-675-5559 ... 800-CC-RIDER ...  408-423-2212
>AA4KB @ N6LDL.#NOCAL.CA.USA.NA / aa4kb.ampr.org / netcom!mojo@apple.com

Adam Rybicki
arybicki@dhw68k.cts.com	or arybicki.lax1b@xerox.com