I want to write 16-bit bootsector code (flat binaries that get cat'd into a .img file and ran on qemu) but I'm getting sick of having to write completely in asm. So I'm looking for a C (and optionally, C++) compiler which can
a. generate 16-bit asm code to be assembled with nasm, or
b. generate 16-bit flat binary files that can be loaded by a BIOS
gcc is out of the question (much to my dismay) because it only generates gas-syntax assembly, and gas is unable to generate proper real mode code; whereas nasm is. VC++ is also out of the question because 1. I don't like it, and 2. it's not [natively] cross-platform. Also, it probably can't generate 16-bit cod either. I know of DJGPP; but the 16-bit compilers are 'experimental' and supposedly quite buggy. I can set up a cross-compiler; but I don't know if gcc will be able to produce 16-bit code even then.
Does anyone know of such a compiler? It must
1. generate 16-bit code that can be assembled with nasm and/or generate 16-bit binary files
2. be able to run on windows and Linux
I don't mean just the program that sits in the first 512-bytes. Say I wanted to write a rudimentary multi-stage bootloader. I would want the first stage to find and load the second stage, which will switch to pmode and then I'll go from there.
GRUB stage2 is written in C, so I know it's possible. All I need is a C compiler for the second stage... or will I have to switch to pmode to run the C code anyway?