提问人:Johndev 提问时间:11/13/2023 最后编辑:Johndev 更新时间:11/13/2023 访问量:81
无法在程序集中加载内核
unable to load kernel in assembly
问:
#include "../drivers/time.h"
#include "../drivers/keyboard.h"
#include "../drivers/display.h"
void _GLOBAL_OFFSET_TABLE_() {}
void main() {
char* video_memory = (char*) 0xb8000;
*video_memory = 'X';
}
我用 C 编写一个简单的内核,我使用可以在代码中使用本教程构建的引导加载程序对其进行测试,我尝试将“X”写入 VGA 内存,映像编译完美,但引导加载程序无法“控制”kernel.c,我做错了什么?(引导加载程序代码与我提供的链接完全相同)
这是我根据要求 compiler.sh:
clear
# Compile MBR
nasm ./boot/mbr.asm -f bin -o mbr.bin
# Compile the kernel_entry.asm code
nasm ./boot/kernel_entry.asm -f elf -o kernel_entry.o
# Compile the C kernel code
gcc -m32 -ffreestanding -c ./kernel/kernel.c -o kernel.o
# Link the object files to create the kernel binary
ld -m elf_i386 -e main -Ttext 0x1000 -o kernel.bin kernel_entry.o kernel.o --oformat binary
# Create directory structure for ISO
mkdir -p iso_root/boot
cp mbr.bin iso_root/boot/
cp kernel.bin iso_root/boot/
# Create ISO image
mkisofs -b boot/mbr.bin -no-emul-boot -boot-load-size 4 -o os.iso iso_root/
答: 暂无答案
评论