Hi everyone
I've wrote my bootloader, so than it loads and jump to the C kernel in real mode with A20 disabled. I'd like to do all the pmode initializing in C. How can I configure GCC or LD to give me 16 bit code?
Using GCC for 16bit development
- AlfaOmega08
- Member
- Posts: 226
- Joined: Wed Nov 07, 2007 12:15 pm
- Location: Italy
Hi,
My advice to you is to use assembly language. As one of the major parts of PMode initialisation, you will want direct control of the segment registers. GCC assumes a flat memory model with no segmentation. I think you will be doing yourself a favour by writing an assembly stub to do the required switching.
IIRC (I have never used a 16 bit C compiler), GCC is generally not used for 16 bit programming. The people in this community who do 16 bit C seem to use Turbo C.
Cheers,
Adam
My advice to you is to use assembly language. As one of the major parts of PMode initialisation, you will want direct control of the segment registers. GCC assumes a flat memory model with no segmentation. I think you will be doing yourself a favour by writing an assembly stub to do the required switching.
IIRC (I have never used a 16 bit C compiler), GCC is generally not used for 16 bit programming. The people in this community who do 16 bit C seem to use Turbo C.
Cheers,
Adam
Use this at your own risk. It is a feature seldom used, and that means it is a feature seldom tested. I'm not sure if the GCC people officially support it at all.Binutils (2.9.1.0.25+) now fully support 16-bit mode (registers and addressing) on i386 PCs. Use .code16 and .code32 to switch between assembly modes.
Also, a neat trick used by several people (including the oskit authors) is to force GCC to produce code for 16-bit real mode, using an inline assembly statement asm(".code16\n"). GCC will still emit only 32-bit addressing modes, but GAS will insert proper 32-bit prefixes for them.
Every good solution is obvious once you've found it.