Page 1 of 1
Writing a Kernel in C++
Posted: Fri Jan 09, 2009 9:47 pm
by LordMage
in 2007, I was working on my kernel and found a tutorial called writing a kernel in C++. I am pretty sure I found it on the osdever.net website. It is still there but parts are missing. I know that I had built a C++ command line using cout and cin from the rest of that tutorial but now it is no where to be found. Sadly, all my kernel code has gone MIA after a few laptop crashes and a divorce. I now, thanks to neon's tutorials at
www.brokenthorn.com, have a good working kernel tested on several real machines, and Virtual PC. I am testing in VPC because of all the emulators it seems to crash more and I figure if it works there it should work anywhere.
Anyway, my question is does anyone know the whereabouts of the rest of the tutorial? I really would like to get working on my command line again.
Re: Writing a Kernel in C++
Posted: Fri Jan 09, 2009 10:41 pm
by Troy Martin
Hey LordMage,
Did a quick scan through the Wayback Machine and it turned up this:
http://web.archive.org/web/200610282048 ... re.net/os/
That should be what you were looking for, the latest revision in the archive was late 2006.
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 7:55 am
by LordMage
Thank you for finding that. I looked at it and he gets part the way through. I guess he never finished. I know it was something like that. I could've sworn it was that exact thing. I guess not since he didn't get to cout or cin in what you found. I guess I will keep looking. I will post what I find if I ever find what I was looking for.
Thanks again for finding that for me.
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 8:47 am
by LordMage
I think I found what I need for cout here
http://forum.osdev.org/viewtopic.php?f= ... 389#p87389 but I still need to find cin and I have a question. I have a printf function already that will process hex and integers. Can I just overload the Monitor& Monitor::operator<< function to take different inputs? Like string, Hex, Int, etc...
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 8:54 am
by xDDunce
C++ supports redefinitions of the same function but with different parameters (cant remember the word used to describe it)
so what i do in my kernel is define loads of functions all caled print() and then give them more and more parameters:
Code: Select all
print(Strings);
print(String s, Colour c);
print(String s, int x, int y);
print(String s, Colour c, int x, int y);
print(unsigned int num);
print(unsigned int num, Colour c);
etc...
that is all aceptable. because all the compiler sees at this point is just the variable types. so just make sure you dont make another print function that uses the same type variables in the same parameter position for the same number of parameter's length. eg:
Code: Select all
print(String s, Colour forec);
print(String s, Colour backc);
will not work because the compiler cannot tell the difference between them by the variable types alone.
hope this helped!
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 10:58 am
by Troy Martin
Oooh, that's some nice code on behalf of Alboin, makes me with I was writing in C++!
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 3:11 pm
by Creature
johnsy2008 wrote:C++ supports redefinitions of the same function but with different parameters (cant remember the word used to describe it)
...
And thanks to C++ you can also do operator overloading! So mix these two together and you get a cout with operator<< clone
!
Re: Writing a Kernel in C++
Posted: Sat Jan 10, 2009 7:27 pm
by xDDunce
god bless C++. i only discovered how make a cout styled operator a few weeks back, on that exact post. before then all i did was call the appropriate print() function. but i guess this is why we use C++, its alot easier