July 29th, 2004, 04:49 AM
I am starting to write an OS so I can learn a bit more about how my computer works with it's hardware. I am trying to write it strictly in C++. I have been looking for the C++ source for a boot loader that I can study so I can see how it works. Does anyone by chance know where I can find something like this? I am sorry to ask b/c it is probably something I should already know but all I can find is stuff in assembly. Thanks in advance.
July 29th, 2004, 05:00 AM
Take a look at linux freebsd Etc they are all open source you just have to find the folder it is located in or search the web.
July 29th, 2004, 05:03 AM
Have you looked at GRUB? It's not Assembler. If I recall it's 32-Bit C, and if you're writing an OS, I don't think you'll have a problem taking C and turning it into C++. Also, I think KDE is done in C++ so you might want to check that out of you're making a GUI.
July 29th, 2004, 05:17 AM
Anytime you need source code in any language check out planet source code.
When death sleeps it dreams of you...
July 29th, 2004, 05:45 AM
Do unto others as you would have them do unto you.
The international ban against torturing prisoners of war does not necessarily apply to suspects detained in America\'s war on terror, Attorney General John Ashcroft told a Senate oversight committee
-- true colors revealed, a brown shirt and jackboots
July 29th, 2004, 09:57 AM
Hmm ya know ive also been wanting to code an OS but im not to sure of what language to code it in/what languages i need to know.....hobbdebub could you please contact me via PM as in i would be interested in the resources you are useing.
July 29th, 2004, 03:03 PM
I have looked around and I do believe that if I am going to write an OS I need to learn assembly. It is need I guess to deal with the lower level aspects of dealing with the hardware. Seems to learn one thing I have to learn 2 more.
July 29th, 2004, 03:40 PM
u can write almost of an O/S in C. However, in some specific areas, on specific hardwares, we need to deal with assembly. Here some example of why:
a) you need to use instructions that cant be mapped to C. You need for example, to craft a special instruction to talk to a device. Or use instructions that change control registers. You cant do it on C
b) you need a very very small program. Some routine, such as 1st level interrupt handler or loader has a size limit. So you need to write it in assemly instead C.
You face those problem on IA-32 architecture for instance. You somebody show you an O/S for IA-32 that is "pure" C, believe me, its b/s. You will need some assembly to finish it.
Other platforms, like PA-RISC, all drivers can be written in C, since device are all memory-mapped.
Anyway, i do recommend that you learn assembly. It will be usefull even if you only code in C. At least for debugging purpose
FORMAT C: Yes ...Yes??? ...Nooooo!!! ^C ^C ^C ^C ^C
If I die before I sleep, I pray the Lord my soul to encrypt.
If I die before I wake, I pray the Lord my soul to brake.
July 29th, 2004, 04:16 PM
You are unlikely to find a bootloader written in C or C++. Seeing as these bootloaders all run in real-mode (in intel), they need to call bios routines. Writing one in C would be awkward because you'd have to write a new C library which would work in real mode, but not call DOS routines (as DOS is not present).
So they use asm.
Also the first part of the bootloader needs to fit in under 512 bytes (can't remember how many). Then you have a second part and sometimes a third part.
Typically all the parts are written in asm. I'm not sure whether the bootloader switches to pmode, or whether the OS does. But in any case, at some point the CPU switches to pmode. In the case of Linux, I'm pretty sure it only switches to pmode after it's loaded the kernel fully (which it does using the bios block IO routines)