简单操作系统:对kmain的未定义依据

时间:2017-10-02 15:43:57

标签: c++ assembly

您好我正在编写一个简单的Os in assembly和c ++我完成了我的.asm文件的编写我对汇编很新,所以我只是复制粘贴并尝试理解代码但是......

    BITS 16


%INCLUDE "print.asm"
extern _kmain

start:
    mov ax, 07C0h       ; Set up 4K stack space after this bootloader
    add ax, 288     ; (4096 + 512) / 16 bytes per paragraph
    mov ss, ax
    mov sp, 4096

    mov ax, 07C0h       ; Set data segment to where we're loaded
    mov ds, ax








    call _kmain

    jmp $           ; Jump here - infinite loop!








    times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
    dw 0xAA55       ; The standard PC boot signature

我有一个c ++文件

void kmain(void)
{
    const char *str = "hello";
    char *vidptr = (char*)0xb8000;  //video mem begins here.
    unsigned int i = 0;
    unsigned int j = 0;

    /* this loops clears the screen
    * there are 25 lines each of 80 columns; each element takes 2 bytes */
    while(j < 80 * 25 * 2) {
        /* blank character */
        vidptr[j] = ' ';
        /* attribute-byte - light grey on black screen */
        vidptr[j+1] = 0x07;         
        j = j + 2;
    }

    j = 0;

    /* this loop writes the string to video memory */
    while(str[j] != '\0') {
        /* the character's ascii */
        vidptr[i] = str[j];
        /* attribute-byte: give character black bg and light grey fg */
        vidptr[i+1] = 0x07;
        ++j;
        i = i + 2;
    }
    return;
}

当我使用

时,我从thembut制作了.o文件
ld -m i386pe -O OS.tmp a.o as.o

它给出错误:::

:Bootloader.asm:未定义对`kmain&#39;

的引用

0 个答案:

没有答案