16位C代码用于实模式内核

16位C代码用于实模式内核

本文介绍了16位C代码用于实模式内核的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何编译我的C内核为16位实模式。我试过各种编译器没有运气。我的bootloader只是将软盘中的原始扇区(我的内核刚好在磁盘上的第一个扇区之后)加载到物理内存地址1000h:0000h,然后跳转到它。我如何编译我的C内核工作在16位实模式?

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?

我的基本内核:

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

    while( 0 )
    {

    }
}

我试过的编译器是GCC,tinyCC和DMC。我的目标是得到一个平坦的二进制文件,我可以跳到开始执行。

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.

推荐答案

首先,建议您查看,其中包含了用于开发自己的操作系统和组件的资源。

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

其次,你考虑过编写一个bootloader在实模式下启动,切换到保护模式,然后然后跳转到您的(32位)编译内核?

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?

这篇关于16位C代码用于实模式内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:22