Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Making basic OS in Assembly

assembly

  • Please log in to reply
17 replies to this topic

#1 spel565

spel565

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 02 November 2011 - 06:00 AM

So I was thinking.. If i wanted to make a basic os (GUI not required) from scratch, is Assembly a appropriate language? How long time would it take to learn the basics of Assembly and make a little OS? What would I be able to do with this OS with only Assembly? (:

At the moment I have a little knowledge of C++, Autoit and Python, and I though that making an operating system would be a good little project.
  • 0

#2 2Root

2Root

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 02 November 2011 - 07:13 AM

You can learn the basics of assembly in a matter of weeks, but understanding memory management concepts will take longer. It could take a while for you to learn OS design concepts and theory. Start with a bootloader and work your way up to the actual OS. With assembly you can do pretty much anything.

MenuetOS was written entirely in assembly.
  • -1

#3 spel565

spel565

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 02 November 2011 - 07:52 AM

You can learn the basics of assembly in a matter of weeks, but understanding memory management concepts will take longer. It could take a while for you to learn OS design concepts and theory. Start with a bootloader and work your way up to the actual OS. With assembly you can do pretty much anything.

MenuetOS was written entirely in assembly.


How long could it take to make a small working OS? (with really no prior knowledge)
How hard is it to make small programs for my OS in assembly then (what kinds of other program would be usable?)? :o

Recommended reading? ;) (know any good books, pdfs, forums w/e) (:
  • 0

#4 2Root

2Root

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 02 November 2011 - 08:43 AM

Operating System Concepts is the book for OS development. I would suggest you learn assembly first or do some reading on OS organization. The FASM forums has a section dedicated to OS construction using FASM as the assembler. flat assembler - View Forum - OS Construction

osdev has valuable information on os development. Expanded Main Page - OSDev Wiki

Here is a good starting tutorial for using NASM to build a simple os. How to write a simple operating system in assembly language

Look at the source for some open source all-asm based operating systems. From where you are starting, making your os load programs is a ways away, you should focus on getting your os to load first.
  • 0

#5 mebob

mebob

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 467 posts
  • Programming Language:C, C++, Assembly
  • Learning:PHP

Posted 02 November 2011 - 02:45 PM

It all depends on what you want the OS to do. Expanded Main Page - OSDev Wiki is a great source, has tutorials for beginners.
  • 0
Latinamne loqueris?

#6 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 02 November 2011 - 03:46 PM

You're going to have to write at least the bootloader in assembly language, but that's not too hard. I'd say C (without standard libraries, mind you) is a good idea.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#7 spel565

spel565

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 02 November 2011 - 04:00 PM

You're going to have to write at least the bootloader in assembly language, but that's not too hard. I'd say C (without standard libraries, mind you) is a good idea.


I dont know much about C (and i dont know alot about other languages either), what is the best way to write a simple OS? Using purely assembly or f.ex. also mix in C and make the classic hybrid thingy?
  • 0

#8 mebob

mebob

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 467 posts
  • Programming Language:C, C++, Assembly
  • Learning:PHP

Posted 02 November 2011 - 04:10 PM

If you find C easier than directly programming in assembly (you probably will) you would either need to program the bootloader (in assembly) to load, say, an ELF file programmed with C, or use a bootloader like GRUB. Either way, you will need at least some assembly coding. The GRUB route is probably easier, as it will load the ELF executable for you.
  • 0
Latinamne loqueris?

#9 dargueta

dargueta

    I chown trolls.

  • Moderator
  • 4854 posts
  • Programming Language:C, Java, C++, PHP, Python, JavaScript, Perl, Assembly, Bash, Others
  • Learning:Objective-C

Posted 02 November 2011 - 04:12 PM

If you find C easier than directly programming in assembly (you probably will) you would either need to program the bootloader (in assembly) to load, say, an ELF file programmed with C, or use a bootloader like GRUB.


Or you can just compile to a raw binary image that can be loaded directly into memory.
  • 0

sudo rm -rf / && echo $'Sanitize your inputs!'


#10 RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1310 posts
  • Location:C:\Countries\US
  • Programming Language:C, Java, C++, PHP, Python, JavaScript

Posted 02 November 2011 - 04:17 PM

MenuetOS was written entirely in assembly.


I think MS-DOS was also built using assembly language.


The resources I like to use are osdev (mentioned earlier) and supernovah (Supernovah).



I would say, practicing assembly language programming would be a good idea. You can use NASM (with combination of ALINK) to make Win32 programs, for practice. After all, practice makes perfect :) .

Also, reading the code is just as important as writing it; if one doesn't read his code, and/or doesn't understand what it does and what it actually should do, then he would, about 99% of the time, get weird results.

It is also a good idea to keep things organized, especially when it comes to protected mode programming, if you want to go that far. Maybe even make the TSS for each program as part of its structure in memory, or in the program file, to make things easier to keep track of (that's sort of what I'm planning on doing for my OS).
  • 0

#11 spel565

spel565

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 02 November 2011 - 04:28 PM

How much time can it take to "learn assembly" and write a simple os, with let say no prior knowledge? :)

How hard (?) /time consuming would it be to write that simple os in just assembly?
  • 0

#12 mebob

mebob

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 467 posts
  • Programming Language:C, C++, Assembly
  • Learning:PHP

Posted 02 November 2011 - 05:58 PM

Well, lets say you wanted to make an OS that starts up and has a simple command line with a few commands. There are many routes you could take. Probably the easiest would be to stay in 16 bit mode and use BIOS interrupts to print text and read keyboard input. The longest part would probably be learning assembly code and learning stuff about OS development.

---------- Post added at 09:58 PM ---------- Previous post was at 09:58 PM ----------

Or you can just compile to a raw binary image that can be loaded directly into memory.

That is what I was referring to when I said 'bootloader'.
  • 0
Latinamne loqueris?





Also tagged with one or more of these keywords: assembly

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download