This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC and memory segments


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Sep 23, 2003 at 12:00:03PM +0300, Petar Penchev wrote:
> Can anybody tell me how to make GCC to use memory segments?
> I mean memory segments like x86 in real mode. 

AFAIK GCC simply doesn't support real-mode x86 platforms.  Well, that's
a half-truth: you can add inline assembler to tell gas to emit 32-bit
address and operand-size overrides, but GCC still generates assembly as
if for a 32-bit flat address-space x86 platform.  And it's not just a
matter of using "unsigned short" instead of "int"; GCC generates all
kinds of weird and wonderful addressing modes that work only on i386+:
scale-index-base seems to be a favourite.

Okay, so now I admit that I'm (very) slowly trying to write a port to
generate i86 code that will work on pre-i386 machines.  (Writing from
scratch, and I think I am/was beyond the point of no return when I
learned that modifying an existing target might have been easier.)  And
I'm as much trying to grok GCC internals as getting a working port, so
success or failure doesn't really matter. :)

I believe DJ Delorie has done some work on realmode x86 code generation.
Here are two links from google (hardly read them myself):

http://gcc.gnu.org/ml/gcc/1999-07n/msg00608.html
http://openbios.infra.de/archiv/1999-07/0794.html

Unfortunately I've lost the link to the machine description and target
header files.  But I remember that they really were a bare-minimum port,
hardly enough to generate really good code (I might be mistaken,
apologies to DJ in that case).


Okay, now to Petar's question.


What I've done so far is to copy&edit functions from config/i386/i386.c
where that seems close.  But of course to work with segments I'd have to
do the work myself!

If anyone is still reading, I'd like some suggestions please.
Ultimately, it'd be nice to be able to generate "huge model" code, where
individual objects may be larger than 64k.  But a good first goal is
something like "large" model, where objects are limited to 64k, but you
can have as many of them as the address space allows.  (16, to be
exact. :)

So how do I work with segments?

Should I try to go all the way and make Pmode refer to that funny
segment:offset type, hoping that by that time register allocation will
be smart enough to be able to allocate segment registers and index
registers independently?  That might even fit into the
GO_IF_LEGITIMATE_ADDRESS scheme of doing things.  Except that GILA takes
an rtx; I don't know how that interacts with register allocation?

Or maybe I should just stick values into the segment registers on an
ad-hoc basis?  So that when I need to access a word in a different
segment, I'd just "force" the "right" segment into ds just before the
instruction goes out?  That way, GCC's guts won't even know about the
segment registers.  Which isn't a half bad thing, since it'd be
uber-cool to be able to do -Dfar=__attribute__((__far__)) so that some
pointers can be near and others far.

Ideas, please?

TIA

bernd

P.S. Before anyone gets all enthusiastic, my port doesn't even compile
yet.  I'm only just finishing what I think I need in i86.h; only after
that will I start on i86.md.  At the moment, I still get
Warning: blah.c:42 `Pmode' undeclared
Which I'll try and figure out later.

(Pay me and I'll think of making promises.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/cqpQ/FmLrNfLpjMRAmt6AJ4sN2cBf+fuMPmH7ArSQ98V7hq+2ACfbcrG
x2ugf0wwxCjyvCpKxu6hUN0=
=vzWm
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]