Suppose, I have a simple Hello world
program which is built in C
. Now How can I boot it during start my PC?
My wish is to make simple hello world Operating System.
I've quite knowledge regarding C
and C++
, how can I boot it? Please let me know. Do I need to learn Assembly language for it?
If yes, then inside Assembly what do I need require to understand first? And where should I go for Assembly (NASM
, MASM
etc..)?
Help would be appreciated!
You could do this by writing a simple bootloader. This OSdev article shows you one way to go about it.
Regarding languages: Any compiled language (C/C++) gets compiled into machine code, which again is 1-1 mappable to assembly instructions. So, in principle you could write most of the bootloader in C/C++.
Printing: The challenge with "booting your own code" is of course that you won't have any drivers or any standard library (so, no printf
-function or cout
). In x86, however, certain parts of low memory (starting at 0xa0000
) is directly mapped to video memory when you boot, meaning that the bytes you write to this part of memory will atuomagically appear on the screen, as text.
Choice of assembler: This is really only a matter of taste. For a simple assembly-language bootloader, you'll want to avoid any particular formatting of the resulting binary. nasm -f bin myfile.asm -o myBootsector
will just assemble the code into a raw binary.
This post has more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With