Page 1 of 2
How do I get Started
Posted: Wed Aug 29, 2007 2:14 pm
by Buck1000
I want to make my own OS, but I have no idea where to start. I know a little ASM and C++, along with a HUGE amount of QBasic. What confuses me the most, is how do I use C++ to write an OS? How will my program run all by itself without an OS, if it isn't coded in Assembly?
Thanks!
Posted: Wed Aug 29, 2007 2:21 pm
by Brynet-Inc
Perhaps you should go learn what a C/C++ compiler actually does
Have fun
Posted: Wed Aug 29, 2007 2:31 pm
by Tyler
Why not set this idea on the shelf for a few years? Go right some basic software in C, then some challenging software, then some difficult software, then come back and have a look at OS Development.
Posted: Wed Aug 29, 2007 2:46 pm
by Kevin McGuire
How will my program run all by itself without an OS, if it isn't coded in Assembly?
How will a program written in assembly run all by it's self - with out a OS?
If you take a look at what some C source compiles into you might be able to start to understand. I assume you know a little about how assembly can run with out a OS, so lets show the assembly for a C function.
Code: Select all
int a()
{
return 1;
}
push %ebp
mov %esp,%ebp
mov $0x1,%eax
pop %ebp
ret
This should show that C will turn into the equivalent of assembly through compilation. Then if you know something written in assembly can run with out a OS, then you should see how something written in C can run with out a OS.
Posted: Wed Aug 29, 2007 5:18 pm
by Combuster
Since you are familiar with QBasic, you can use FreeBasic - It is suitable for kernel development and its syntax is largely compatible with that of quickbasic.
Still, you should know assembly to know what happens under the hood (you can't use the basic runtime in kernel land).
Posted: Wed Aug 29, 2007 5:34 pm
by Buck1000
Well, ASM runs without an OS by sending signals directly to the microprocessor, right? So, then, when you compile the ASM code, it gets turned to HEX, right? And then... um... well, im stumped... If you guys could explain it to me that would really rock, as I'm 13, and I have school and other things I need to do, and I don't really have the time to become an advanced C++ programer...
Posted: Wed Aug 29, 2007 5:47 pm
by Alboin
Buck1000 wrote:Well, ASM runs without an OS by sending signals directly to the microprocessor, right? So, then, when you compile the ASM code, it gets turned to HEX, right? And then... um... well, im stumped... If you guys could explain it to me that would really rock, as I'm 13, and I have school and other things I need to do, and I don't really have the time to become an advanced C++ programer...
- The PC boots.
- It checks to see if there's anything in it to run.
- It finds your floppy.
- As you installed your boot sector* onto it, the PC finds it and loads it into memory from the floppy.
- Your boot sector runs.
*Your boot sector is a piece of assembly code that loads the rest of the OS that the PC didn't. Moreover, it prepares the PC for the rest of your OS.
That's it. Your boot sector is running. Your code is running. (That is, your compiled code; be it C, C++, or assembly.) You can write an OS in assembly. However, the language is nearly irrelevant. The only thing that truly matters is that you know your architecture.
I suggest, after learning a bit more on general programming, you download the Intel\AMD and study those.
Posted: Thu Aug 30, 2007 8:58 am
by Buck1000
Ok cool, thanks!
Posted: Thu Aug 30, 2007 9:24 am
by Buck1000
And for the Intel manuals, it says you can order a hard-copy of some of them. Is that free? Because I downloaded all of them, but I would like to have them as books.
Posted: Thu Aug 30, 2007 6:31 pm
by JackScott
Yes, ordering the hard copy is free. It's an awesome service, IMHO. Unfortunately, they sometimes become sold out due to demand, and so you might have to wait a while (I had to wait several months after first hearing about the service before I could order).
Posted: Thu Aug 30, 2007 6:59 pm
by Brynet-Inc
Yayyak wrote:Yes, ordering the hard copy is free. It's an awesome service, IMHO. Unfortunately, they sometimes become sold out due to demand, and so you might have to wait a while (I had to wait several months after first hearing about the service before I could order).
Can someone confirm this? what are the requirements? any shipping/handling etc costs?
Posted: Fri Aug 31, 2007 4:56 am
by JamesM
Yes, I can confirm they're free. They prefer to ship to companies though (so i gave them my employer's address). They're out of stack atm until mid september.
@OP: Please, please seriously consider not trying to code an OS atm. You obviously have no idea how anything works at any low level, please, just do some other C, asm projects to work out how things work, you'll be doing us all a favour because we won't have to answer questions about elementary programming problems that a little experience will teach you much better.
Posted: Fri Aug 31, 2007 6:35 am
by Combuster
@OP: Please, please seriously consider not trying to code an OS atm. You obviously have no idea how anything works at any low level, please, just do some other C, asm projects to work out how things work, you'll be doing us all a favour because we won't have to answer questions about elementary programming problems that a little experience will teach you much better.
The only offence at sanity I see is that he wants to use a language for OSDev that he hasn't mastered (and with that, how the corresponding tools work, see other threads).
I'm going to stick with my suggestion to use a basic compiler for the sole reason he knows the language. I recently put up a
freebasic barebones which can be used as a starting point.
For the rest all I see are system architecture questions. Very well a side effect of programming in a high level language, but its hardly an excuse to not answer his question, let alone telling him to (...) off.
Buck1000 wrote:How will my program run all by itself without an OS, if it isn't coded in Assembly?
All compiled programs run directly on the processor. That means that they use what the processor has to offer. When they need more than just the processor, they ask the processor to send messages to all the hardware of the computer.
An OS is basically the big bully that prevents processes to directly access hardware. Instead of doing things for themselves they have to ask the OS.
The only thing that is different when developing an OS is where you ask for help. Now its just you and the plain hardware, instead of you and the OS. For several compiled languages, that does not make a difference. There are still a few that are hopelessly dependent on the system of the OS that you can't use them for other tasks. Quickbasic isn't autonomous enough, while assembly is the most autonomous language there is. In between you have GCC, G++, Object Pascal, FreeBasic, Visual C, and many many more. Some are closer to the processor and some are closer to the operating system, The only thing that's needed is that the language does not
require the OS. People use C because they think its the best trade-off between ease and power. Some other people use assembly for the very same reason. You decide what you want.
If you still want to use C or C++ (or any non-basic in your case) for OS development, You will first need to know the language inside out before trying to use it for OS development.
Posted: Fri Aug 31, 2007 8:51 am
by JamesM
For the rest all I see are system architecture questions. Very well a side effect of programming in a high level language, but its hardly an excuse to not answer his question, let alone telling him to (...) off.
I didn't tell him to (...) off at all. All I stated was that writing an OS is an immensely complex task that is not to be attempted lightly. And the fact that his posts suggested he has no knowledge of how a processor works at all (not trolling, just stating a percieved fact), suggested to me that it probably isn't wise him starting an OS yet. Especially considering he has started 3 topics recently on information that is quite clearly stated in (a) Bran's tutorials and (b) the wiki.
I apologise for any offence to the OP, and I didn't answer his question because others had already answered it admirably.
JamesM
Posted: Fri Aug 31, 2007 10:29 am
by Buck1000
Well, I think I'm gonna go ahead and look into FreeBasic, and maybe learn some more C++. I'm also gonna go ahead and study the processor and see how it works, and maybe learn a little more ASM. See ya in a little while! (Oh, and JamesM, thanks for the tip, because I think your right, I really am not ready to start on an OS, so I'm gonna go learn some more before I come back.)