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.
Writing a Kernel in C++
Writing a Kernel in C++
Getting back in the game.
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Writing a Kernel in C++
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.
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++
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.
Thanks again for finding that for me.
Getting back in the game.
Re: Writing a Kernel in C++
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...
Getting back in the game.
Re: Writing a Kernel in C++
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:
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:
will not work because the compiler cannot tell the difference between them by the variable types alone.
hope this helped!
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...
Code: Select all
print(String s, Colour forec);
print(String s, Colour backc);
hope this helped!
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Writing a Kernel in C++
Oooh, that's some nice code on behalf of Alboin, makes me with I was writing in C++!
Re: Writing a Kernel in C++
And thanks to C++ you can also do operator overloading! So mix these two together and you get a cout with operator<< clone !johnsy2008 wrote:C++ supports redefinitions of the same function but with different parameters (cant remember the word used to describe it)
...
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: Writing a Kernel in C++
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