Well there is a snippet
here at DIC. I am not too confident about this snippet.
Basicly to do this you need to understand a little bit about what BIOS reads off of a disk when it is "booting off of disk". The first thing it does is read the first 512 bytes (which is why so many viruses used to strive to be under 512 bytes) and put them at 0000h:7C00h (note that this is a segmented address). It then preforms a little check that the last two bytes are 0x55 0xAA. If all is good it passes execution on to 0000h:7C00h (the information it just copied off of the disk). This is ussualy a JMP to the actual begining of the code, the bytes that are jumped over tend to hold static data (such as information on how the rest of the operating system is stored on the disk). It is up to the rest of this 512 bytes to setup and load the rest of the operating system from the disk.
On a MS-DOS "non-boot" disk the JMP leads to a bit of code that prints out "This is a non-system disk\nPress any key to continue."
Ussualy these little "boot" programs are written in assembly due to the need to do as much as you can in 512 bytes. If you do want to use C, I would recommend that you have your compiler output to asm so that you can edit away all the little overhead and then assemble the rest. I have also read about using the .obj file and extracting the code from that.
Here are some links that might be usefull:
How Boot Loaders WorkWotsit.org Binaries Goto the FAT32. The first chapter is on the boot sector format. It also tells you about the boot sector of hard drives.
BIOS interrupt call a nice discription of the BIOS int 13 (lowlevel disk access) call that you would use to load the rest of the operating system.
Ralf Brown's Interrupt List is a great place to find information.
I hope that this information helps you. Writing your own little operating system is a LOT of fun. However you will have to let go of C/C++ just a bit (or a lot) as most of the libraries depend upon OS specific information.
OSLib is an OS independent C library.
This post has been edited by NickDMax: 2 Mar, 2007 - 02:12 AM