X-Git-Url: http://git.dujemihanovic.xyz/projects?a=blobdiff_plain;f=boot.s;h=3a8adc70a9d275e2e17faa53e6772aee0289e36c;hb=d826097f3b032247dd0396f8cf64b2fa775cea68;hp=eb115d0324dd6a2e8e83d94aee9d197d71299392;hpb=b85f8e94af0b9720083f5cd48092ead24e6004c3;p=nameless-os.git diff --git a/boot.s b/boot.s index eb115d0..3a8adc7 100644 --- a/boot.s +++ b/boot.s @@ -1,23 +1,33 @@ bits 16 ; boot sectors run in real mode org 7c00h ; boot sector is loaded at 0x7c00 - mov di, printing_numbers - call print +_start + mov [boot_drive], dl ; BIOS sets dl to number of boot drive, we don't want to forget this - mov dx, 0DEADh ; number to print - call print_word - mov dx, 0BEEFh - call print_word + mov bp, 8000h ; Move the stack away + mov sp, bp - mov di, goodbye - call print + 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 - jmp $ + 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 -printing_numbers: db "Printing some random hex numbers", 0 -goodbye: db "Thank you for your attention", 0 + 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