]> git.dujemihanovic.xyz Git - nameless-os.git/blob - boot.s
Read bytes from boot drive
[nameless-os.git] / boot.s
1 bits 16 ; boot sectors run in real mode
2 org 7c00h ; boot sector is loaded at 0x7c00
3
4 _start
5 mov [boot_drive], dl ; BIOS sets dl to number of boot drive, we don't want to forget this
6
7 mov bp, 8000h ; Move the stack away
8 mov sp, bp
9
10 push cs
11 pop es
12 mov bx, 9000h ; Load at 0000:9000
13 mov dh, 2 ; Load 5 sectors
14 mov dl, [boot_drive] ; Load from boot drive
15 call read_sectors
16
17 mov dx, [9000h] ; Print value at 9000h, should be 0xDEAD
18 call print_word
19 mov dx, [9000h + 512] ; Print value at 9200h, should be 0xBEEF
20 call print_word
21
22 jmp $ ; Endless loop
23
24 %include "print.s"
25 %include "disk.s"
26
27 boot_drive resb 1 ; Reserve 1 byte for boot drive number
28
29 times 510-($-$$) db 0 ; fill with 0 until 0x1fc is reached
30 dw 0AA55h ; BIOS MBR signature
31
32 times 256 dw 0DEADh ; Fill in 2nd sector with 0xDEAD
33 times 256 dw 0BEEFh ; Fill in 3rd sector with 0xBEEF