views:

32

answers:

2

I'm going to write and test a bootloader. In order to do this, I am planning to copy the bootloader onto a floppy image file and mount it in a VM.

However, I'm not sure where to put the bootloader's machine code. Does it just get dumped into the first few bytes of the file?

A: 

its been a VERY long time but if i recall in DOS it was stored in the MBR. i believe its still the same today

http://en.wikipedia.org/wiki/Master_boot_record

scphantm
That doesn't really answer my question, though. Where **in the IMG file** does it get stored?
George Edison
+2  A: 

The boot sector of the floppy was the first sector. If you're talking about a raw floppy image (1440K), it should be the first 512 bytes of the image file.

From memory, this gets loaded by the BIOS into 7c00:0000 (real mode) and then jumps to that address.

The DOS boot floppies had a 3-byte JMP instruction there to jump over the Disk Parameter Block (DPB), which detailed the attributes of the disk. But, if you're in total control of the disk and your boot code, I don't think you need to follow that convention. I don't recall any BIOS' checking what was loaded for validity (though admittedly it was a long time ago).

paxdiablo
Perfect. That's exactly what I wanted to know.
George Edison