16 bit C code for real mode kernel

你离开我真会死。 提交于 2019-12-10 16:03:18

问题


I don't know how to compile my C kernel for 16 bit real mode. I have tried a variety of compilers with no luck. My bootloader simply loads raw sectors from the floppy (my kernel lives right after the first sector on the disk) to the physical memory address 1000h:0000h then jumps to it. How can I compile my C kernel to work in 16 bit real mode?

my basic kernel:

void OSmain()
{
    unsigned char *videoram = (unsigned char *) 0xb8000;
    videoram[0] = 65;                                     /* character 'A' */
    videoram[1] = 0x07;                                   /* forground, background color. */

    while( 0 )
    {

    }
}

the compilers I have tried are GCC, tinyCC, and DMC. My goal is to get a flat binary file that I can jump to to begin execution.


回答1:


First, I recommend you check out the OSDev Wiki, which has resources upon resources for developing your own OS and components.

Second, have you considered writing a bootloader in assembly that starts off in real mode, switches to protected mode, and then jumps to your (32-bit) compiled kernel?



来源:https://stackoverflow.com/questions/6720566/16-bit-c-code-for-real-mode-kernel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!