简体   繁体   English

16 位 C 实模式代码 kernel

[英]16 bit C code for real mode kernel

I don't know how to compile my C kernel for 16 bit real mode.我不知道如何为 16 位实模式编译我的 C kernel。 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.我的引导加载程序只是将原始扇区从软盘(我的 kernel 就在磁盘上的第一个扇区之后)加载到物理 memory 地址 1000h:0000h 然后跳转到它。 How can I compile my C kernel to work in 16 bit real mode?如何编译我的 C kernel 以在 16 位实模式下工作?

my basic kernel:我的基本 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.我尝试过的编译器是 GCC、tinyCC 和 DMC。 My goal is to get a flat binary file that I can jump to to begin execution.我的目标是获得一个可以跳转以开始执行的平面二进制文件。

First, I recommend you check out the OSDev Wiki , which has resources upon resources for developing your own OS and components.首先,我建议您查看OSDev Wiki ,其中包含用于开发您自己的操作系统和组件的资源。

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?其次,您是否考虑过在汇编中编写引导加载程序,以实模式启动,切换到保护模式,然后跳转到(32 位)编译的 kernel?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM