无法在低级别的 c 中启动功能

问题描述

我的引导加载程序有问题,当我调用一个函数来编写屏幕-> printString 时,该函数没有启动。我不知道为什么。 代码是:

/*generate 16-bit code*/
__asm__(".code16gcc\n");
/*jump boot code entry*/
__asm__("jmpl $0x0000,$main\n");

void printString(char *);

/* user defined function to print series of characters terminated by null character */
void main() {
     /* calling the printString function passing string as an argument */
     printString("Hello,World");
     while(1);
} 
void printString(char *string) {
     __asm__ __volatile__("movb $'H',%al\n");
     __asm__ __volatile__("movb $0x0e,%ah\n");
     __asm__ __volatile__("int  $0x10\n");
     while(*string) {
          __asm__ __volatile__ (
               "int $0x10" : : "a"(0x0e00 | *string)
          );
          string++;
     }
}

链接文件,ld 是:

ENTRY(main);
SECTIONS
{
    . = 0x7C00;
    .text : AT(0x7C00)
    {
        *(.text);
    }
    .sig : AT(0x7DFE)
    {
        SHORT(0xaa55);
    }
} 

生成文件是:

bash -c "gcc -c -g -Os -march=i686 -m16 -ffreestanding -Wall -Werror ../project/kernel/bootloader/boot.c -o boot.o"
bash -c "ld -static -melf_i386 -Ttest.ld -nostdlib --nmagic -o boot.elf boot.o"
bash -c "objcopy -O binary boot.elf boot.bin"

我想知道功能启动

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)