Writing a Kernel in C++

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Writing a Kernel in C++

Post 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.
Getting back in the game.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Writing a Kernel in C++

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Re: Writing a Kernel in C++

Post 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.
Getting back in the game.
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Re: Writing a Kernel in C++

Post 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...
Getting back in the game.
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: Writing a Kernel in C++

Post 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!
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Writing a Kernel in C++

Post by Troy Martin »

Oooh, that's some nice code on behalf of Alboin, makes me with I was writing in C++!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Writing a Kernel in C++

Post 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 ;)!
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: Writing a Kernel in C++

Post 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 :D
Post Reply