1 ; x86 bootloader for nameless-os, MBR portion
9 ; set up segment registers
14 mov sp, 0x7c00 ; just under the soon-to-be-loaded VBR, should be more than sufficient space
16 ; perform self-relocation
20 mov cx, 0x100 ; 256 words = 512 bytes
22 ; some BIOSes may set CS to 0x7c0, work around that
26 ; check for int 13h ext
28 mov byte [BOOT_DRIVE], dl
29 ; look for active partition
45 ; look for any other active partitions, if they exist the partition table is invalid
56 ; load active partition's VBR
60 push bx ; save pointer to partition table entry
63 ; check is the VBR bootable (ends with 0x55 0xaa), if not halt
64 cmp word [0x7dfe], 0xaa55
67 pop si ; hand off partition table entry to VBR
101 ; edx = start LBA of where to read
104 ; set up temporary DAP
112 mov dl, byte [BOOT_DRIVE]
116 add sp, 16 ; dump our temporary DAP
147 read_fail: db "Error reading stage 2", 0
148 invalid_mbr: db "Invalid partition table", 0
149 no_os: db "No OS found", 0
150 no_int13_ext: db "INT 13h extensions not found", 0
152 times 440-($-$$) db 0
159 .chs_start times 3 db 0
161 .chs_end times 3 db 0
166 .chs_start times 3 db 0
168 .chs_end times 3 db 0
173 .chs_start times 3 db 0
175 .chs_end times 3 db 0
180 .chs_start times 3 db 0
182 .chs_end times 3 db 0