Page 1 of 2

Don't know where to begin

Posted: Mon Nov 09, 2015 2:25 pm
by atlas9719
Hi,
sorry for my english, I am Italian and I'm trying to improve it but i often make some mistakes.
I am interested in developing an OS, as I am an IT student.
I have good knowledge in assembly and C but..I don't know where to begin.
What is the first thing I have to do? I suppose the Kernel.
So, the next question: how to develope the Kernel?
I want to start from scratch.

Thank you all for your help.

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 2:29 pm
by intx13

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 2:32 pm
by atlas9719
I've already read, but I'm really confused

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 2:34 pm
by intx13
atlas9719 wrote:I've already read, but I'm really confused
What are you confused about?

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 2:42 pm
by atlas9719
That's a good question.
What OS i have to use, what languages, what kind of editors, ..

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 2:47 pm
by intx13
atlas9719 wrote:That's a good question.
What OS i have to use, what languages, what kind of editors, ..
All those things and more are covered on that first page I linked.

Re: Don't know where to begin

Posted: Mon Nov 09, 2015 9:50 pm
by Schol-R-LEA
As Intx13 says, the wiki page does cover that. I suspect you are having a bit of jitters, though, so let me reassure you by say that, for the standard x86 PC, almost any combination of a 32-bit C compiler, x86 assembler, and linker will work, and you can use any general programmer's editor for writing the code in. Some tools may require additional configuration, but if the compiler and/or assembler will produce freestanding executables (i.e., an executable file without the OS-specific initializer and without automatically linking in the standard libraries) with few or no runtime requirements, you should be able with enough effort get a working OS from it.

That having been said, the most direct course of action is to use the GNU toolchain. It is the same set of tools used for Linux development, and dozens of hobby operating systems have been written with them. They are the common denominator for most OS dev, and even if you are using a different toolchain you should at least have a passing familiarity with them, and specifically with using them from the shell (that is, the command line). In particular, you will want to have at least a basic understanding of the gcc compiler driver program, the ld linker (which can be invoked from GCC or by itself), the gas assembler (ditto), the make build tool, and the dd raw-file reading and writing utility.

If you are using Linux or FreeBSD, you probably already have these installed; on MacOS X, they are the default toolchain for XCode (the standard Apple IDE and toolkit), as well. If you are hosting your development from Windows, there are a number of ported Unix-like environments you can use, with Cygwin and MinGW being the most commonly used (with Cygwin generally being preferred). If you haven't used these tools before, I recommend familiarizing yourself with them (downloading and installing them if necessary), so that when the wiki or the message board inmates use them in examples you at least can figure out what they are talking about.

Note that a lot of OS-Devs prefer to use the Intel style of assembly syntax rather than the AT&T syntax used by gas; Netwide Assembler (NASM) is quite popular, in particular. However, you should learn to read AT&T assembly, even if you don't want to use it, as it is the style produced by GCC.

Regardless of the toolchain you use, it is highly recommended that you set up a separate installation specifically for cross-compiling your OS. Operating systems have somewhat special requirements regarding executable file generation, library defaults, and build environment, so keeping your OS-Dev tools distinct from your general programming tools is very important. The wiki has a pages on configuring GCC and Visual Studio for this purpose.

As for the editor, that's a wide open field, with no real winners or losers - use whatever you feel the most comfortable with, as long as it will save plain text files you should be fine. If you decide to use an IDE such as Eclipse, Code::Blocks, or Visual Studio, you will have to configure it to use the cross-compiler, assuming you are using one.

There are two other tools you should use, and you'll want to give some thought as to the specific ones you'll want to use. The first is version control software, and, not to put too fine a point on the matter, anyone who is doing any kind of substantive software development project in 2015 without using version control and an offsite repository for their code has already made their first mistake. Which one you use - Subversion, Git, Mercurial, Bazaar, even old reliable CVS - is less important than being absolutely dedicated to using it consistently whenever editing your code.

The other tool you will want is an emulator (e.g., Bochs, QEMU) or a virtualizer (VirtualBox, Virtual PC, VMware) for testing your OS in. Again, this may sound like an optional tool, but practically speaking, you will need one, preferably one that allows you to debug the emulated OS from the emulator. While it is your choice which one to use, I personally recommend Bochs, as it is the easiest to configure, load, and run, and it has the most comprehensive debugging suite. You will probably want two, actually, for cross-testing (to make sure that you haven't relied on some particular facet of the emulator) before going to live hardware - in which case I suggest VirtualBox as the second one.

With that out of the way, all you need to do is pick your poison. Before going on, though, perhaps you'll want to consider these questions, and maybe answer them for us as well:
  • Why are you interested in OS dev? There are a lot of reasons people get into the hobby, and knowing your motivations can give you a better idea of what you should be doing here (and give us some idea of what advice to give you). A lot of devers want to learn about it, out of curiosity; others may see it as the ultimate macho challenge of their programming skills, or just love programming from the bare metal; still others may have broader ambitions.
  • What do you want to do with it? Do you have a specific goal in mind, or just want to sort of experiment around with things? Do you want to re-implement an existing system, or are you looking to try something unusual? This wiki page might give you some inspiration regarding your direction.
  • How do you want to do it? Are you looking to design a specific part first, or develop in several areas at once? Are you planning to use assembly alone, C and assembly, or assembly with some other language? What kind of kernel architecture do you want to use? I know that this is exactly the question you came here to ask, but you should ask yourself what you want to use, not us.
The last thing I want to say is, don't set your goals too high at the start. OS dev is among the hardest, if not the very hardest, programming challenge a coder can undertake. It takes patience and perseverance to get anywhere with it. Don't take on too much at the start, and be prepared to start over once you've made the beginner's mistakes (and you will make at least some of them). Take your time with it, and build up to the higher levels over time.

Re: Don't know where to begin

Posted: Tue Nov 10, 2015 5:42 am
by embryo2
Schol-R-LEA wrote:I suspect you are having a bit of jitters, though, so let me...
Nice introductory article! But may be we need more on toolchains (not only GCC) and environments (Linux, Windows, Mac)? However, the main directions are given in a simple way.

Re: Don't know where to begin

Posted: Tue Nov 10, 2015 5:58 am
by embryo2
atlas9719 wrote:I don't know where to begin.
As it was said there are tons of texts about "how to start". But I want to mention one a bit different way.

It's very simple. Just learn Java :)

Yes, in fact Java is like C, but much simpler than C. And there's no different toolchains and environments. It's always the same! No need for studying a lot of command line utilities. No need for studying a lot about compilers and how they pack your code within a number of different formats. It's even possible not to learn assembly (but of course, it's required to know the processor's instruction set). You even haven't to select your preferred IDE because there's Eclipse, which is dominant in the area of Java development. And finally - Java really can help you make more money, than C (isn't it important?).

And if you have decided to try this way then the road ahead is very short. Learn Java (it's simple!). Learn about processor's instructions (x86 32-bit for starters). Learn how to run processor instructions from Java. Look at this project and create your own with even better features! That's all. Simple and quick :)

P.S. If you have Java related questions - feel free to ask me.

Re: Don't know where to begin

Posted: Tue Nov 10, 2015 1:11 pm
by Combuster
Java can certainly be fun, but since embryo might be the only one able to answer anything, you might want to stick to the formal recommendation of using C Bare Bones instead of trusting his whims. :wink:

As far as editors are concerned, do you have any editor you currently use for programming? If we know what you're used to, it's easier to say something about how you would go with it (or say its useless and come with 101 personal favourites anyway).

Re: Don't know where to begin

Posted: Sun Feb 14, 2016 10:34 am
by Muazzam
atlas9719 wrote:That's a good question.
What OS i have to use, what languages, what kind of editors, ..
The OS you're already using would perfectly work. So does the default text editor of your OS.

For the language, I'd suggest using an assembly language with FASM (assembler). (Since you've already mentioned that you know assembly.)

I can assure you that C is complex. At least for a newbie.

Re: Don't know where to begin

Posted: Sun Feb 14, 2016 11:00 am
by iansjack
The OP also said that he had a good knowledge of C. I believe that using only assembler is a classic Beginner's Mistake. Use it where you have to, but nowhere else.

Re: Don't know where to begin

Posted: Sun Feb 14, 2016 11:39 am
by ashishkumar4
lol I wished some one could teach me assembly :/

Re: Don't know where to begin

Posted: Sun Feb 14, 2016 8:40 pm
by azblue
ashishkumar4 wrote:lol I wished some one could teach me assembly :/
One thing I'd recommend for learning assembly is DOS's debug; you can type in assembly commands and execute them one at a time, seeing how the commands change the registers and flags. It's how I learned.

Re: Don't know where to begin

Posted: Mon Feb 15, 2016 2:39 am
by Muazzam
ashishkumar4 wrote:lol I wished some one could teach me assembly :/
Assuming that you know Hindi (from your name), http://ocw.vu.edu.pk/Videos.aspx?cat=Co ... urse=CS401 would surely help.

It's also on YouTube: https://www.youtube.com/watch?v=MOtvz7-59Sw.