Starting an OS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Stephen

Starting an OS

Post by Stephen »

I know that there is reference material all over the net that attempts to break down the beginning processes of OS design, however, for my benefit and others' benefit, I'd like to break down the process. I have not written an OS, but I'd like to.

The first step I have seen repeated times - learn ASM, or at least know some ASM. The ASM knowledge needs to be picked up in order to write the bootstrap process. However, how MUCH ASM does one really need to know in order to write a bootstrap? Does the ASM only really come in handy when writing the bootstrap, or is it something that will be needed later (I want to write the OS in C/C++)? I would like to at least understand the little ASM that is used in the bootstrap process.

To confirm my suspicion of this first step, someone please reply to this post, letting me know if this is correct or not. If this should not be the first step, please point out what the first step should be.

I would appreciate any resources that could be pointed out; whether it be tutorials, book references, etc.

Thanks in advance. ???
nullify

Re:Starting an OS

Post by nullify »

Stephen wrote: The first step I have seen repeated times - learn ASM, or at least know some ASM. The ASM knowledge needs to be picked up in order to write the bootstrap process. However, how MUCH ASM does one really need to know in order to write a bootstrap?
Actually, you do not *have* to write the bootstrap loader yourself; GRUB can serve that purpose nicely in many cases. In the event you do wish to write a bootstrap loader, then yes you will need to know some assembly. If you already have a basic grasp, it should not be too difficult to pick up anything new you might encounter.
Stephen wrote:Does the ASM only really come in handy when writing the bootstrap, or is it something that will be needed later (I want to write the OS in C/C++)?
Although a majority of an operating system can be done in C/C++, you cannot escape from assembly completely. (After all, this is an /OS/ you are writing, what do you expect? ;p ) e.g., for things like loading the IDTR register, enabling paging, and doing port I/O. Of course this could be inline in the C file, but you still must know some assembly.
Stephen wrote:I would appreciate any resources that could be pointed out; whether it be tutorials, book references, etc.
Check out the ".:QuickLinkz:." and "Book Recommendations" sticky threads at the top of this forum.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Starting an OS

Post by Pype.Clicker »

imho, the very only thing you have to understand is not ASM itself, but rather the machine architecture:
  • what the stack is and how it can be used to call procedures, transmit arguments, etc.
  • what are bit masking, shifting etc., why it is more efficient to compute (x<<6)+(x<<4) than x*80 ... (being able to translate an expression like x=(x&(~FLAG1))|FLAG2 in basic AND and OR operations on X and see immediately what X will be after it.
  • how a function like "strcpy" or "strlen" work ...
  • what are registers and how the compiler use them
no need for knowing every opcode if you want to make an OS in C(++), but you may not have the slighest misunderstanding on what the compiler does for you ...
and if you have doubts, i would suggest that you know enough assembly to understand what the code generated by GCC does (once you know basics of CPU architectures, you can guess it even on a machine you do not know :p )

In other words, looking at the output of a disassembly must not surprise you, even if you wouldn't have been able to write that yourself.
Post Reply