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]

gcc and real-mode i386


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

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

Things looked fine until I started making function calls.  After much
head-scratching I traced this to gcc (2.95.2) generating bare ret and call
instructions.  Problem: __asm__(".code16") wasn't enough.  While the
assembler now generated the correct prefixes for all the addl, pushl, etc.
instructions, "call" remained a 16-bit instruction, but gcc assumed a
32-bit return address.  Because on i386 a function's parameters are
above the return address, this means all paramter accesses go berzerk.

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

Would it be better to modify one of the target macros to depend on
TARGET_REAL_MODE or something?

Bernd Jendrissek
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6nl7aDaF1aCTutCYRAmp8AJ92FRi4Zf4TVa9IUh6ZMJ5ud6eFEwCcCPPF
Q3bJBP7+5D7MOnS519iHG0E=
=+ZUf
-----END PGP SIGNATURE-----


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