Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

djsteffey

OS Development

This topic is 6286 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got interested in seeing what I could do trying to make an OS last night and I have a couple simple things working like it boots up the computer, displays a few messages, and allows the user to type on the keyboard. It will repeat what the user types and it they type reboot then the computer reboots.....this is all done in assembly. I was wondering where does c/c++ take over in os development ? I certainly dont want to code the whole thing in assembly, or is that what you are supposed to do ? "I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma." - Mr. T

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Sounds like you''re trying to develop an OS, but you don''t yet know the difference between an OS and a command shell! I''d go check a book on operating systems out of the library before I tried to go much further.

Share this post


Link to post
Share on other sites
i understand the difference. I guess then my question is does the whole command shell have to be in asm ? Like say I want to print stuff out to the screen....I know I cant use the c/c++ fuunctions like cout or printf because they call os functions that do the output for them. So do I write all those basic funnctions in asm like printf (cout), getf (cin), etc.... ?


"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

Share this post


Link to post
Share on other sites
The only thing that actually ''needs'' to be written in assembly is the bootloader and some low-level initialization stuff in the kernel, like detecting CPU type, switching to protected mode, setting up the interrupt vector and page tables and such. Everything else can be written in C or C++, or some other high level language.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well, printf, getf, malloc and so on are actually implemented in your C library. These in turn make system calls into your OS. (In DOS, they generated interrupts or made BIOS calls)

So you just need to write the system calls, then a C library.

Your command shell has _nothing_ to do with the operating system, and can be written as a user space application just like anything else. This is why you can use bash, tcsh, etc under Unix... or windows explorer in place of Command.com in windows.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Well, printf, getf, malloc and so on are actually implemented in your C library. These in turn make system calls into your OS. (In DOS, they generated interrupts or made BIOS calls)

So you just need to write the system calls, then a C library.


Yes, but the system call-functions and the C library can be implemented in C (or any other high level language) for the most part. There may be some exceptions, for example: you will have to write assembly wrappers around your system-functions if those system-functions are implemented in C and you decide to implement system calls by interrupts, since interrupt handlers need to return with the IRET instruction instead of the RET instruction (the assembly wrappers might not be needed if you have a compiler that can generate code for interrupt routines). And not only DOS use the interrupt mechanism for system calls; Linux is another example.

Edited by - Dactylos on September 24, 2001 7:50:02 PM

Share this post


Link to post
Share on other sites
quote:
Original post by ncsu121978
i understand the difference. I guess then my question is does the whole command shell have to be in asm ? Like say I want to print stuff out to the screen....I know I cant use the c/c++ fuunctions like cout or printf because they call os functions that do the output for them. So do I write all those basic funnctions in asm like printf (cout), getf (cin), etc.... ?


"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T


The main thing here is that it depends on which boot strap loader you use. I saw one a while back that allowed you to do your whole shell using C/C++. And then it thought you how to create a C/C++ compiler to code applications for your shell. I'll have to find the name as I was planning on using it. I guess, most of the asm was already implemented in the bootstrap loader. Anyhow, hope this helps out...



"And that's the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP's Invasive Production Activation Technology!

"gitty up" -- Kramer

Edited by - Cyberdrek on September 24, 2001 8:05:17 PM

Share this post


Link to post
Share on other sites
Indeed. If you want write your OS in C/C++, there are two things you need: A compiler which can output to (insert executable file format here), and a bootloader which can load (insert executable file format here).

~~~~~~~~~~
Martee

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!