Page 1 of 1

16-bit C with DJGPP (GCC)

Posted: Wed Dec 11, 2002 12:00 am
by Anon
How do you generate 16-bit C code with DJGPP(GCC)?

RE:16-bit C with DJGPP (GCC)

Posted: Wed Dec 11, 2002 12:00 am
by Anonymous Coward
you don't

try Turbo C or Watcom C

RE:16-bit C with DJGPP (GCC)

Posted: Fri Dec 13, 2002 12:00 am
by moth
It can generate 16bit/32bit mixed code that will run on a 386+ machine in real mode.  The code will not run on a 286 or less.  I'm actually using this for my boot loader.  Before your 16bit code add:

__asm__ (
     ".code16    \n"
     ".code16gcc \n"
);

Then before your 32bit code add:

__asm__ (
     ".code32\n");
);

You will probably also want to turn off all alignment optimizations to avoid bogus code generation with some builds of GCC:

-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1