OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 2:48 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 3:27 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
I have messed around with some Python crap, but I want a really fun project. I want to learn C or ASM. What are some good resources for both that you can recommend? Is the ANSI C book by K&R still good? As for virtual machine, I have Xubuntu Linux installed on one.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 7:30 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 06, 2015 6:41 am
Posts: 97
Location: Netherlands
Getting Started is a good page to read.
Real mode assembly I is a good place to start for asm, also google: "x86 + unknown_instruction" is a good way to learn, and I personally really like this page as well.
For C development I think the Bare Bones tutorial might be a good place to start.
More tutorials can be found on the Tutorials page.
If you're looking for books, there is a wiki page about that, as well as a forum thread.

And, not to be mean but because you're asking about things already described on the wiki, you might what to read How To Ask Questions as well, especially the part under "Research".


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 9:00 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 31, 2016 9:53 pm
Posts: 81
Location: San Diego, CA
A lot of people are going to tell you that this is a bad way to learn C. And they may be right. But don't let that stop you.

I had never written a single line of C when I first came to this board many years ago. It's a steep learning curve, but this kind of project really gives you a deep understanding of the language.

I'd recommend doing a couple fun user land programs first, so that you can learn and debug in a more user-friendly environment than an emulator.

_________________
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 4:51 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
crunch wrote:
A lot of people are going to tell you that this is a bad way to learn C. And they may be right. But don't let that stop you.

I had never written a single line of C when I first came to this board many years ago. It's a steep learning curve, but this kind of project really gives you a deep understanding of the language.

I'd recommend doing a couple fun user land programs first, so that you can learn and debug in a more user-friendly environment than an emulator.


Where did you learn actual C though?


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 5:23 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 18, 2016 2:46 pm
Posts: 170
I actually learned C by creating hacks for games when I was 14 and coding my own games using 3D Gamestudio (when I was 12).
Never read one book about it and also learned ASM while hacking games.
If you want to be a lil bit faster then me you should read some tutorials and then create some useful programs first.
You actually learn alot of asm when you do some easier crackmes (plus its alot of fun too)
Even writing shellcode is alot of fun. But hes actually right - you shouldnt learn C by coding your own OS because you will hate it some months later and have to recode it completely.
Start on your current OS and do some usermode apps as he suggested to learn the basics so you dont have to rewrite the OS completely later :)


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 5:39 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 31, 2016 9:53 pm
Posts: 81
Location: San Diego, CA
Ch4ozz wrote:
I actually learned C by creating hacks for games when I was 14 and coding my own games using 3D Gamestudio (when I was 12).
Never read one book about it and also learned ASM while hacking games.
If you want to be a lil bit faster then me you should read some tutorials and then create some useful programs first.
You actually learn alot of asm when you do some easier crackmes (plus its alot of fun too)
Even writing shellcode is alot of fun. But hes actually right - you shouldnt learn C by coding your own OS because you will hate it some months later and have to recode it completely.
Start on your current OS and do some usermode apps as he suggested to learn the basics so you dont have to rewrite the OS completely later :)


This is true. I didn't even follow my own advice, and pretty much learned C by reading/writing some osdev tutorials. And sure enough I ended up rewriting the entire OS once I actually stepped back to write some userland code 8) (and a maybe another time after that!)

As far as where to learn... if you already have a strong background in other languages - you mentioned python - then many of the basics will be the same, i.e. for loops, conditionals, variables, etc. The major hurdle (and the source of power) in C is pointers. You NEED to know pointers as well as you know the back of your hand if you want to have any chance of doing something significant in C.

Here's a decent article explaining some pointer basics: http://karwin.blogspot.com/2012/11/c-pointers-explained-really.html

_________________
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sat Dec 03, 2016 10:50 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
Honestly, I don't know if I'm ready for this yet based on these replies I got. Sure, I messed around with some code, but couldn't really execute an actual project. I would love to, but I just have trouble executing things (computer pun not intended :D ).

I really need to understand.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Sun Dec 04, 2016 12:03 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
crunch wrote:
The major hurdle (and the source of power) in C is pointers. You NEED to know pointers as well as you know the back of your hand if you want to have any chance of doing something significant in C.


One should also know undefined behavior, so it doesn't come as a surprise why perfectly looking code isn't working / why the compiler "breaks" it.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Wed Dec 07, 2016 4:54 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
I am starting to wonder if any programming (let alone system programming) is for me.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Wed Dec 07, 2016 7:55 am 
Offline
Member
Member
User avatar

Joined: Tue Aug 02, 2016 1:52 pm
Posts: 286
Location: East Riding of Yorkshire, UK
Mark12 wrote:
I am starting to wonder if any programming (let alone system programming) is for me.


Don't give up, you'll figure it out eventually :)

_________________
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Thu Dec 08, 2016 3:07 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 18, 2016 9:50 am
Posts: 138
Location: New York New York
Personally, when I started doing hobbyist OS stuff I already knew enough C to be dangerous and ended up actually learning it properly as I worked on my OS project. It worked okay for me, so I'd recommend the same for you -- because you can feel free to try if you're up for the challenge, but if you don't already know how to use a C compiler to make something executable then it's going to be incredibly aggravating to try and figure it out as you go with the tutorials on the wiki.

I would recommend a straightforward interactive tutorial series like this to get started learning C at all: http://www.learn-c.org/

Also, K&R is a pretty good reference if you already know C, but I wouldn't recommend it as a beginner's learning tool. For that, I would actually with a completely straight face recommend something like C for Dummies (my first exposure to C was C++ for Dummies, which was great, but at 11 I just couldn't wrap my head around OOP).

So here's what I would recommend:

1. Learn C using something like the tutorial series above along with a beginner's reference book like C for dummies. (already knowing python should make picking up the concepts way easier, so it shouldn't be too bad. The hardest parts will be all of the features that C is lacking compared to python and understanding how C actually produces machine code as opposed to the dynamic interpreted nature of python)

2. Once you're starting to feel comfortable getting into C, if you don't have one already either install a Linux distro on a spare machine or in a VM and get familiar with using GCC and the actual C toolchain in an actual local development environment (there's C compilers for every machine and OS you can think of, but Linux is by far still the most convenient platform for building things in C)

3. Think of some silly but nontrivial project to build in C on your own from scratch (a little game using SDL, maybe even a webapp using KORE.io, whatever you want as long as it's more advanced than a couple of functions in a single source file) and spend like a month of weekends implementing the thing. This will give you valuable insight into how really implementing and designing software in a systems language like C works in a way that nothing else can teach you, and it'll familiarize you more in practice with how the building and linking system in C works.

4. Somewhere in/between steps 2 and 3 above, start doing some research into how the CPU in your computer really works using wikipedia and google which should help you turn up some stuff like: https://www.youtube.com/watch?v=H4Z0S9ZbC0g -- learn the basics of how the CPU is connected to memory and peripherals, how it communicates, reads and writes to them, how it starts up and reads instructions, what registers and the stack are and how they're used, so that you can:

5. Start learning x86 assembly code. Besides manually twiddling bits with a hex editor, this is the lowest level way to write code for your CPU and you *WILL* need to know it to do things in your OS that C has absolutely no concept of, Ex: setting up special registers to configure the processor to work the way you want, setting up memory management, writing to I/O ports, ETC. You need it to do a lot of little glue stuff, and either way you're going to want to know how your computer operates if you're writing the software that makes it go. And it goes hand-in-hand with 4 as learning assembly will teach you about the machine and learning about the machine will make assembly make more sense. This seems like a really in-depth resource: http://opensecuritytraining.info/IntroX86.html

6. Roll up your sleeves and do what a real production dev does: With your wits and your new knowledge of the x86 architecture and C in one hand and google and the wonderful resource that is the OSDev wiki in the other, start at the start and decide a goal at a time what you want to accomplish (first: figure out how the PC boots code and get some boot code running on the bare hardware, second: learn how the keyboard controller works and get some code running that can handle some basic input...) and then use your resources and your intelligence to make it happen. Most of writing an OS is learning how the devices you want to interface with in your computer work one by one from datasheets and other resources and then hacking and debugging away with that information in mind until things start working. The rest is your imagination, really.

It's a long road, it will be frustrating, but it's worth it, it's equally rewarding, and you can do it! Remember this hilariously ironic anti-advice that I want to say is from It's Always Sunny: "Why keep doing something if you're not instantly great at it?"

_________________
The OS is P5. Don't expect it to build.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Thu Dec 08, 2016 11:26 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
Haha. I actually almost purchased C++ For Dummies the other day. Thanks for breaking it down for me.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Fri Dec 09, 2016 4:05 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 10, 2016 7:35 am
Posts: 167
Location: Lancaster, England, Disunited Kingdom
Mark12 wrote:
Haha. I actually almost purchased C++ For Dummies the other day. Thanks for breaking it down for me.



No no no no no....
C for Dummies not C++ for Dummies..

C++ is a MUCH bigger learning task and is a lot further away from the machine architecture. Stick with strictly C.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Fri Dec 09, 2016 4:38 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 18, 2016 9:50 am
Posts: 138
Location: New York New York
I get the impression that he actually read my post while you did not.

Anyhow I'm sure that was just a big ramble, but I'm glad if I was of any help, Mark. Best of luck! Or, actually, I prefer the Japanese 'ganbarimasu!' -- It's used like english speakers use 'good luck', but literally means something more like 'do your best'. Because, while there's an element of luck to most anything, your perseverance is something you can actually control.

I'm not a weeb, I swear.

_________________
The OS is P5. Don't expect it to build.


Top
 Profile  
 
 Post subject: Re: Want to develop my first operating system
PostPosted: Fri Dec 09, 2016 9:37 pm 
Offline
Member
Member
User avatar

Joined: Sat Dec 03, 2016 3:13 am
Posts: 64
Yes, I'm just a dude who wants to someday (at the very least) make a console prompt along the lines of "[name]>_" and it will be all retro-looking. :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot], RayanMargham, SemrushBot [Bot] and 229 guests


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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group