X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=boot.s;h=3a8adc70a9d275e2e17faa53e6772aee0289e36c;hb=d826097f3b032247dd0396f8cf64b2fa775cea68;hp=76880b009eded1d15e93792478061d121a920859;hpb=f9f4f8ebffb463d53ae5a239ddfbe8380f258b8b;p=nameless-os.git diff --git a/boot.s b/boot.s index 76880b0..3a8adc7 100644 --- a/boot.s +++ b/boot.s @@ -1,18 +1,33 @@ bits 16 ; boot sectors run in real mode org 7c00h ; boot sector is loaded at 0x7c00 - mov dx, 0DEADh ; number to print - mov cl, 0 ; column - mov ch, 0 ; row - call print_word - mov dx, 0BEEFh - mov cl, 0 - mov ch, 1 +_start + mov [boot_drive], dl ; BIOS sets dl to number of boot drive, we don't want to forget this + + mov bp, 8000h ; Move the stack away + mov sp, bp + + push cs + pop es + mov bx, 9000h ; Load at 0000:9000 + mov dh, 2 ; Load 5 sectors + mov dl, [boot_drive] ; Load from boot drive + call read_sectors + + mov dx, [9000h] ; Print value at 9000h, should be 0xDEAD + call print_word + mov dx, [9000h + 512] ; Print value at 9200h, should be 0xBEEF call print_word - jmp $ + jmp $ ; Endless loop %include "print.s" +%include "disk.s" + +boot_drive resb 1 ; Reserve 1 byte for boot drive number + +times 510-($-$$) db 0 ; fill with 0 until 0x1fc is reached +dw 0AA55h ; BIOS MBR signature - times 510-($-$$) db 0 ; fill with 0 until 0x1fc is reached - dw 0AA55h ; BIOS MBR signature +times 256 dw 0DEADh ; Fill in 2nd sector with 0xDEAD +times 256 dw 0BEEFh ; Fill in 3rd sector with 0xBEEF