Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,493 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,358 people online right now. Registration is fast and FREE... Join Now!




C++ Boot disc

 
Reply to this topicStart new topic

C++ Boot disc

levyr
1 Mar, 2007 - 08:05 PM
Post #1

New D.I.C Head
*

Joined: 1 Mar, 2007
Posts: 2


My Contributions
Does any one know how to or have the code to create a boot disk using C++ for a pc without an operating system?
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: C++ Boot Disc
2 Mar, 2007 - 02:00 AM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,867



Thanked: 53 times
Dream Kudos: 550
My Contributions
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 Work
Wotsit.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
User is offlineProfile CardPM
+Quote Post

levyr
RE: C++ Boot Disc
2 Mar, 2007 - 06:18 AM
Post #3

New D.I.C Head
*

Joined: 1 Mar, 2007
Posts: 2


My Contributions
Thanks very much. I will start reading up on some of the links that you sent and try to write the code!



QUOTE(NickDMax @ 2 Mar, 2007 - 03:00 AM) *

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 Work
Wotsit.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.


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 05:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month