Post subject: Programming Language Advice Posted: Mon Oct 03, 2011 2:38 am
1337 Beta Collector
Joined Tue May 03, 2011 2:08 am
Posts 1414
Location New Tokyo-3
Favourite OS Windows 8 RP
Hey, all. I'm seriously considering starting my own custom OS, and I was wondering if there is any one "best" language to work from scratch in. I realize this is a huge commitment, and I'm going to take the time to learn what I'm doing, but I'd like some advice on where to start. The only solid goal I have in mind right now is that I want to write a 32- or 64-bit OS.
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 3:43 am
1337 Beta Collector
Joined Tue May 03, 2011 2:08 am
Posts 1414
Location New Tokyo-3
Favourite OS Windows 8 RP
Jecag wrote:
My advice personally...
ASM, C++.
gogogo.
I was planning on investigating C++ already, actually. I looked at ASM, but had trouble making any sense of it. I may have to give it another look...
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 4:26 am
Newbie Beta Collector
Joined Mon Oct 03, 2011 4:00 am
Posts 1
Favourite OS 5.1.2600, SP2
Very low level programming would be done in assembler language of some type - you might try learning this by debugging or reversing open source code - lots of books on the subject. Knowledge of C language is also fundamental.
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 9:05 am
Amateur Beta Collector
Joined Tue Sep 21, 2010 12:47 pm
Posts 220
Favourite OS IRIX 5.3 XFS 12/94
maybe you should think about what your OS should look like, what it shall support and how it is programmed. there is no sense writing a kernel that prints "Hello world" and calling this an OS, when there is no way of loading some kind of program, and then you should provide some interfaces for programs to start/stop, access hardware, ...
before starting to read programming tutorials, you should better start here
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 6:58 pm
1337 Beta Collector
Joined Sat Nov 28, 2009 4:05 pm
Posts 2360
Incredible low level i.e. critical loading stuff in ASM, can't be done anywhere else. Write as much of the backbone of the OS in C as you can. You'll be kicking yourself if it's all ASM and you can't make sense of it / make it work (only write the ASM where there's no way of doing it in C basically).
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 9:43 pm
Amateur Beta Collector
Joined Tue Sep 21, 2010 12:47 pm
Posts 220
Favourite OS IRIX 5.3 XFS 12/94
I wouldn't suggest writing in interpreted/JITed highlevel languages such as Java or .Net, you had to write quite a lot of lowlevel stuff to accommodate a runtime for this code, which probably exceeds your knowledge when you don't have any architectural idea until now
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 10:43 pm
1337 Beta Collector
Joined Tue Apr 15, 2008 12:13 am
Posts 1008
Location With Waldo
Favourite OS Windows 7 RTM
neonsonicboy wrote:
Incredible low level i.e. critical loading stuff in ASM, can't be done anywhere else. Write as much of the backbone of the OS in C as you can. You'll be kicking yourself if it's all ASM and you can't make sense of it / make it work (only write the ASM where there's no way of doing it in C basically).
I think this is your best advice. I would also say, I think you can use some C++ instead of C sometimes, but you have to ask your self, what are you writing (what is it's purpose and what will it look like). ASM, in my opinion, is extremely hard to learn, so you have to decide if it is worth learning in your case. If it is not, or things just aren't clicking for you once you start, my advice would be to work on a modification for an OS that is already made.
Post subject: Re: Programming Language Advice Posted: Mon Oct 03, 2011 10:51 pm
1337 Beta Collector
Joined Tue May 03, 2011 2:08 am
Posts 1414
Location New Tokyo-3
Favourite OS Windows 8 RP
I'll learn as much ASM as I need to to create a base. If I wanted to modify an existing OS I'd just use Linux, after all.
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
Post subject: Re: Programming Language Advice Posted: Tue Oct 04, 2011 4:28 pm
Newbie Beta Collector
Joined Sat Aug 28, 2010 5:11 pm
Posts 43
Location Berlin
Favourite OS UNIX v6, Plan 9
If you're interested, you might enjoy "Lions' Commentary on UNIX 6th Edition" by John Lions. It really is a classic (I'm reading it right now and am almost finished) and contains the whole source code of the Unix version 6 kernel, which ran on PDP-11s. The code quality is superb (although an older, more "liberal" C dialect is used) and it's great fun to read; it's not easy though...programming operating systems isn't a piece of cake.
Post subject: Re: Programming Language Advice Posted: Tue Oct 04, 2011 4:33 pm
1337 Beta Collector
Joined Tue May 03, 2011 2:08 am
Posts 1414
Location New Tokyo-3
Favourite OS Windows 8 RP
I'm aware of this. Any idea where I might find a copy of this book? In real life, that is. Not Internet retailers.
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
Post subject: Re: Programming Language Advice Posted: Tue Oct 04, 2011 4:59 pm
Pro Beta Collector
Joined Thu Jul 01, 2010 1:08 pm
Posts 397
Location Over here!
Favourite OS AMI BIOS
soulman wrote:
Seeing as C++ is down, I'll suggest .NET.
.NET needs runtime libraries, so you can't write a CustomOS in it, until you'll write an independent compiler(like Singularity is using). ___
I really suggest the Assembler, as you need it for bootloader if you won't use GRUB(just like me). If you want to start with OSDeving - start from 16-bit real-mode first, it will teach you the basics, then, you can switch to Protected Mode, where you are entirely on your own(no interrupts, goodbye BIOS ), own drivers, own everything. So... If you are not curious how it works (I am writing pmode system for this, of course...), you need a really big motivation.
For additional reference, visit wiki.osdev.org, there are some bare-bones for real mode system (512 bytes is a little bit too small, next challenge - roll it into two-stage system ), try to read FreeDOS code. If you want to make a PMode OS in ASM - MenuetOS code reading. If you want to just real-mode - try MikeOS for reference.
MugenFox wrote:
neonsonicboy wrote:
Incredible low level i.e. critical loading stuff in ASM, can't be done anywhere else. Write as much of the backbone of the OS in C as you can. You'll be kicking yourself if it's all ASM and you can't make sense of it / make it work (only write the ASM where there's no way of doing it in C basically).
I think this is your best advice. I would also say, I think you can use some C++ instead of C sometimes, but you have to ask your self, what are you writing (what is it's purpose and what will it look like). ASM, in my opinion, is extremely hard to learn, so you have to decide if it is worth learning in your case. If it is not, or things just aren't clicking for you once you start, my advice would be to work on a modification for an OS that is already made.
ASM is not that really hard to learn. It depends on your determination.
_________________ Helping you help us help you help us all. 21686148-6449-6E6F-744E-656564454649
Post subject: Re: Programming Language Advice Posted: Wed Oct 05, 2011 4:57 pm
Amateur Beta Collector
Joined Thu Aug 09, 2007 3:56 pm
Posts 176
Location Serbia
Favourite OS Windows Lupus Project
ASM and C definitely. http://www.osdever.net is a great resource for getting some stuff together. I recommend readding through open-source codes to see how people have done stuff - BUT do write your own code from scratch, recycle, don't just C/P pieces of code, learn what it does, investigate, see how it can be done better.
You should always know that writting a usable OS is not a one man job, although it can be done, it's a matter of time, dedication and knowlegde, and you can accomplish more with a team than on your own. Rely on the community if you're making an open-source project too.
_________________
May our software be open-source, and our women closed-source.
Awesome! Downloading now. (chuckle) If I'm LUCKY, I'll have a very, VERY basic OS running by next summer. We'll see how it goes.
_________________ My brother had a book he would hold with pride/A little red cover with a broken spine/On the back he hand wrote a quote inside/"When the rich wage war, it's the poor who die"
Post subject: Re: Programming Language Advice Posted: Tue Oct 11, 2011 2:10 am
Amateur Beta Collector
Joined Fri Dec 24, 2010 11:12 pm
Posts 179
Location /dev/chair
Favourite OS DreckigOS v0.007 Alpha
I'd say to keep it simple all ASM. That's what I uses for OS Dev because it runs fast and is fast to write once you get all the subroutines you need written.
Post subject: Re: Programming Language Advice Posted: Tue Oct 11, 2011 8:29 pm
Newbie Beta Collector
Joined Sun Sep 18, 2011 10:08 am
Posts 20
Favourite OS Longhorn 4051
You will need to learn some ASM. ASM is not hard to learn, its actually one of the simplest imperative language. The hard thing is to figure out how to use the primitives to get the things done.
1) Figuring out what instructions are there and the "usual" way to use them. Reading other people's (commented!) asm code is a good place to start go get a hang of how things are usually done. You don't need to know all instructions, but be familiar with instructions for moving data between registers and memory, the adressing modes, branching (jmp, call and conditional instructions like je="jump on equal", jne="jump on not equal" etc.), the arithmetic instructions (add, sub, mul, div), bit operations (shift left and right) and logical operations (and/or/not/xor) and for the latter group realize what you use them for (i.e. setting/clearing/toggling bits etc.).
2) Another important thing to understand is the whole Intel architecture and segments, paging etc.
A good resource for all these things are the Intel manuals:
Especially the first few chapters of "Basic architecture", followed by the first few chapters of the System Programming Guide is a good place to understand the overall architecture.
I would recommend C over C++ at least for the initial part. C++ introduces its own headaches such as requiring more of the C runtime library to be working (by inserting function calls in your code). The linker and naming conventions are more complex making interoperability with your ASM bits that much harder. This is usually not a problem in plain C. I recommend the NASM (Netwide Assembler) due to its ease of use and ability to easily output objects in all kinds of formats (including "plain" binary, i.e. no headers etc.).
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.