实模式内核的 16 位 C 代码
我不知道如何为 16 位实模式编译 C 内核。我尝试过各种编译器,但没有成功。我的引导加载程序只是将原始扇区从软盘(我的内核位于磁盘上第一个扇区之后)加载到物理内存地址 1000h:0000h,然后跳转到该地址。如何编译我的 C 内核以在 16 位实模式下工作?
我的基本内核:
void OSmain()
{
unsigned char *videoram = (unsigned char *) 0xb8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* forground, background color. */
while( 0 )
{
}
}
我尝试过的编译器是 GCC、tinyCC 和 DMC。我的目标是获得一个可以跳转到开始执行的平面二进制文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我建议您查看 OSDev Wiki,其中包含用于开发您自己的操作系统和组件的资源。
其次,您是否考虑过在汇编中编写一个引导加载程序,该引导加载程序以实模式启动,切换到保护模式,然后然后跳转到您的(32位)编译内核?
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?