We are working on a project to learn how to write a kernel and learn everything. We have a boot loader loaded and it works. However, we have a problem loading the kernel. I will start with the first part:
bootloader.asm:
[BITS 16]
[ORG 0x0000]
;
; all the stuff in between
;
; the bottom of the bootstrap loader
datasector dw 0x0000
cluster dw 0x0000
ImageName db "KERNEL SYS"
msgLoading db 0x0D, 0x0A, "Loading Kernel Shell", 0x0D, 0x0A, 0x00
msgCRLF db 0x0D, 0x0A, 0x00
msgProgress db ".", 0x00
msgFailure db 0x0D, 0x0A, "ERROR : Press key to reboot", 0x00
TIMES 510-($-$$) DB 0
DW 0xAA55
;*************************************************************************
Boot. Startup is too long for the editor, without forcing it to intercept and suppress. In addition, the bootloader and the kernel work in barrels, as we get the message "Welcome to our OS." Anyway, the next kernel for the kernel at the moment.
kernel.asm:
[BITS 16]
[ORG 0x0000]
[SEGMENT .text] ; code segment
mov ax, 0x0100 ; location where kernel is loaded
mov ds, ax
mov es, ax
cli
mov ss, ax ; stack segment
mov sp, 0xFFFF ; stack pointer at 64k limit
sti
mov si, strWelcomeMsg ; load message
call _disp_str
mov ah, 0x00
int 0x16 ; interrupt: await keypress
int 0x19 ; interrupt: reboot
_disp_str:
lodsb ; load next character
or al, al ; test for NUL character
jz .DONE
mov ah, 0x0E ; BIOS teletype
mov bh, 0x00 ; display page 0
mov bl, 0x07 ; text attribute
int 0x10 ; interrupt: invoke BIOS
jmp _disp_str
.DONE:
ret
[SEGMENT .data] ; initialized data segment
strWelcomeMsg db "Welcome to our OS", 0x00
[SEGMENT .bss] ; uninitialized data segment
Using nasm 2.06rc2, I compile as such:
nasm bootloader.asm -o bootloader.bin -f bin
nasm kernel.asm -o kernel.sys -f bin
We write the bootloader.bin file to the floppy disk as such:
dd if=bootloader.bin bs=512 count=1 of/dev/fd0
We write kernel.sys to the floppy disk as such:
cp kernel.sys /dev/fd0
As I said, this works in the barrel. But booting from a floppy disk turns out like this:
...........
:
: OpenSUSE 11.2, GNOME, AMD x64
, , , , . , . , . GRUB . , , , GRUB.
EDIT: 512 , ( ) . , 512 . .