16-bit C with DJGPP (GCC)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Anon

16-bit C with DJGPP (GCC)

Post by Anon »

How do you generate 16-bit C code with DJGPP(GCC)?
Anonymous Coward

RE:16-bit C with DJGPP (GCC)

Post by Anonymous Coward »

you don't

try Turbo C or Watcom C
moth

RE:16-bit C with DJGPP (GCC)

Post 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
Post Reply