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]

Re: gcc and real-mode i386


> > Some while ago I tried to build a bootloader for i386 machines, but
> > using gcc.

 Have a look at:
http://freshmeat.net/projects/gujin/
 There is a graphical bootloader (for Linux) completely written in C
 with GCC (but few assembly instructions). In alpha - i.e. it should
 boot most PC's, not all. Arround 1 Mbyte of C source + e2fs + zlib
 libraries, libraries are nearly unmodified. Approx 100 K of executable
 with all options.
  
> > I started search-and-destroying all occurrences of "call" to "calll"
> > and "ret" to "retl" but then gave up rather than wonder if I got *all*
> > the instances.

 There is also a problem with "leave" - and parameter passing/reference.
 It is partly solved by ".code16gcc" in newer binutils.

> >  Has anyone else done this already?  (If after-2.95.2
> > gcc now does The Right Thing, sorry, I'll go and RTFM.)

 GCC-2.7.3 does the right thing - but optimises a lot less.

> Another approach is to have the startup code switch to 32 bit protected
> mode early on and use gcc without modification.

 But then you are switching from protected/real mode very often.
 Imagine for instance that - for older VESA 1 video cards, you want
 to use the "trace" interrupt (interrupt at each instruction) to record
 each "out" instruction executed - and so deduce how to change the
 graphic window... switch from protected to real mode at each instruction?
 Moreover, sometimes the BIOS is _really_ tricky and will notice you
 are in protected (virtual) mode.

 Using 32 bit versions of the instructions in 16 bit default increases
 a little the size of the code - but the difference is far less than
 the size you get by rewritting cleanly a software.

>  This is probably less
> work and less error prone than hacking gcc to support x86 real-mode.

  You do not need to change a bit of GCC - but maybe add an option
 to insert automatically ".code16gcc" in the assembler file generated.
 The only unavailable construct is the multiplication/division of
 "long long" values because you cannot use any library assembled
 without ".code16gcc".

  Etienne.



___________________________________________________________
Do You Yahoo!? -- Pour dialoguer en direct avec vos amis, 
Yahoo! Messenger : http://fr.messenger.yahoo.com


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