views:

493

answers:

4

Preferably well comment and with some associated docmentation and a Makefile.

Just for clearity, that's the less than 512 bytes (512 bytes - partition table) of machine code that gets loaded by the Bios and is responsible for chaining to the secondary bootloader in your boot partition.

Edit: Both David's and bdonlan's answers look promising. The minimal Dos link goes to a Debian source package for the MBR, but the commented Windows 2000/XP MBR looks like it has more detailed comments.

+1  A: 

Here's someone's commented disassembly of the Windows 2000/XP MBR: http://mirror.href.com/thestarman/asm/mbr/Win2kmbr.htm

David
+1  A: 

Probably the bootloader's source code will be in assembly.

So, even if you don't find source code and you know assembly you can read the MBR with a disassembler. I've done it in the past, it's not very difficult.

Usually the bootloaders store their code right after the MBR sector. They use the MBR only for some init code and then they load the 1st sector.

Nick D
I can, I just wanted something where the BIOS calls were already commented so I didn't have to find my old BIOS reference (God only knows where it's buried). And even better if someone's already documented the intent of the code. Reading undocumented assembly, not real bad but annoying, figuring out WHY they did something much more difficult.
NoMoreZealots
+1  A: 

For a minimal DOS MBR, take a look here. For a more complete bootloader, take a look at GRUB. And here's one on google code search that can be viewed without extracting.

bdonlan
+1  A: 

You can see FreeBSD's boot manager here: http://svn.freebsd.org/viewvc/base/stable/8/sys/boot/i386/boot0/.

Bastien Léonard
That's REALLY well comment code there. It is very nice!
NoMoreZealots