x86 Segment register use

David Fernandez dfernandez@cct.co.uk
Mon Jul 10 16:26:00 GMT 2006


On Mon, 2006-07-10 at 12:12 -0400, Young, Michael wrote:
> > 	Could anyone there tell which segment registers does the compiler use
> > (CS, DS, ES, FS, GS), or if it doesn't use any at all and rely on the
> > default segments all the time?
> > 
> > 	Is there any way to tell it that a specific variable resides, or is
> > addressable only through a specific segment register?
> 
> By "use" do you mean to ask whether segmented pointers are supported in the
> Intel GCC C++ compiler?  I asked a similar question a week or two ago, and
> the answer was "no".  (Recall that segmented memory architecture is not
> supported on many of the target platforms for GCC, so this would be an target
> specific extension, and one that is fairly invasive, as well.)  I believe that
> the GCC C++ compiler only supports the "tiny, flat" model on iapX86.  
> 
I was thinking in protected mode flat model addressing... but because of
the old times I said segments instead of selectors. Usually CS and DS
selectors are used by default in most instructions.

I just wanted to know if gcc expects the selectors set in some special
way, and how many of them, as well as if there is any method to tell gcc
to use a specific selector for some specific variables...

> I know this is a GCC maillist, and it may be heresy, but I'd recommend looking
> at the Watcom C++ Compiler (www.openwatcom.org) if you are looking for segment:offset
> type pointers (48 bits).  Be aware that you may have to give up other language 
> feature in exchange - I'm not sure how up-to-date / std compliant the Watcom compiler
> is, particularly for advanced template handling.



More information about the Gcc-help mailing list