Please, does anybody know how to link boot with kernel? For example I have this code for boot:
[BITS 16]
[ORG 0x7C00]
[global start]
[extern _main]
start:
call _main
cli
hlt
and this for my C++ file:
#include <iostream>
#include <string>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
Now I'll compile .cpp file to .o file and .asm file to .o file. But how can I now link that files to kernel.bin? Its there some code for it? Will this code works? Please help me.
Firstly, you cannot use the C/C++ Standard Library because, in a hobby OS, it doesn't exist*.
Secondly, your C++ code seems to be in 32Bit format while your Assembly code is in 16Bit format. These cannot be linked unless both are 16 or both are 32.
I recommend looking at the OSDev Wiki (user786653 posted that too)... It has many helpful resources to get you on your way to writing an Operating System.
If you really want to start from scratch using 16Bit Assembly, and you want to be able to use 32Bit C++ code, you will have to do the following steps:
(Note to do this you must have a high level of knowledge in C/C++ and at least some knowledge in Assembly)
*If you programmed in your own library then disregard the first statement.
Hope this helps!
-Adrian
Look at C++ Bare Bones from the OSDev wiki. But your code is currently very far from being able to use iostream.
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