How do I get Started

Programming, for all ages and all languages.
Buck1000
Posts: 16
Joined: Wed Aug 29, 2007 2:12 pm
Location: Seatac, WA

How do I get Started

Post 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!
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Perhaps you should go learn what a C/C++ compiler actually does ;)

Have fun :)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post 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.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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).
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Buck1000
Posts: 16
Joined: Wed Aug 29, 2007 2:12 pm
Location: Seatac, WA

Post 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...
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post 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.
C8H10N4O2 | #446691 | Trust the nodes.
Buck1000
Posts: 16
Joined: Wed Aug 29, 2007 2:12 pm
Location: Seatac, WA

Post by Buck1000 »

Ok cool, thanks!
Buck1000
Posts: 16
Joined: Wed Aug 29, 2007 2:12 pm
Location: Seatac, WA

Post 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.
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Post 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).
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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? :?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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
Buck1000
Posts: 16
Joined: Wed Aug 29, 2007 2:12 pm
Location: Seatac, WA

Post 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.)
Post Reply