1 ; x86 bootloader for nameless-os, MBR portion
8 cli ; we really don't want to be interrupted during relocation
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
44 ; look for any other active partitions, if they exist the partition table is invalid
55 ; load active partition's VBR
62 ; check is the VBR bootable (ends with 0x55 0xaa), if not halt
63 cmp word [0x7dfe], 0xaa55
96 ; edx = start LBA of where to read
99 ; set up temporary DAP
107 mov dl, byte [BOOT_DRIVE]
111 add sp, 16 ; dump our temporary DAP
141 read_fail: db "Error reading stage 2", 0
142 invalid_mbr: db "Invalid partition table", 0
143 no_os: db "No OS found", 0
144 no_int13_ext: db "INT 13h extensions not found", 0
146 times 440-($-$$) db 0
153 .chs_start times 3 db 0
155 .chs_end times 3 db 0
160 .chs_start times 3 db 0
162 .chs_end times 3 db 0
167 .chs_start times 3 db 0
169 .chs_end times 3 db 0
174 .chs_start times 3 db 0
176 .chs_end times 3 db 0