I have read a little about Operating Systems and now I am thinking of going for programming an operating system.
Now, I don't have an old box that I can experiment on, so I downloaded VMware free edition and installed it. Now I am good to go except for a few problems.
1- I don't know how to write a program to the boot sector of a floppy drive. I have a little knowledge on that such as it should be exactly 56 bytes, etc etc.
2- Even if I manage to write a hello world program and know how to write it to a floppy drive, but this is 2010 and I don't have a floppy or a floppy drive. VMware does have a feature of loading a floppy image on the machine, but I don't know how I would write that program to the floppy image. If I manage to do that, it would be simple from then on.
3- I do know that it is simple for hello world programs but when I get to writing a kernel, I would have to have a boot loader (I could go for GRUB or LILO but writing a boot loader myself would be simpler than that)...
4- Last but definitely the least, if I would get some links to sites which can help me from starting to write an operating system to loading the floppy image to VMware, that would be very convenient. (Though coding isn't fun if it's THAT easy, but still, since I don't have a teacher or a book whom I could look towards for help, I would need something.)
It only uses assembly which makes sense for such a low level (I'd say as I personally llike asm) but it should be easy to use C for a lot of stuff that's based on what you do in this tutorial (like actually doing something with the "OS")
Edit:
Of course you won't be able to use the stdlib. And of course you'll be clever when linking the asm and the C stuff together.
In order to write your own operating system you need a good working knowledge of Assembly programming language and/or other programming languages, but you will need Assembly regardless.
To write to the boot sector you'll need a code such as this(only for x86):
"entry start
start:
mov ax,#0xb800
mov es,ax
seg es
mov [0],#0x41
seg es
mov [1],#0x1f
loop1: jmp loop1"
The first of this bit is the statement declaring the entry point of the boot sector and control over it. 0xb800 is the address of video memory. Register ax will contain the value of 0xb800, which is the video memory. The # is for representing an immediate type of value.
To display any character on the screen, you need to write two bytes to the video memory.
Remember, you're using a floppy disk to boot the drive to you said. Here's the rest of the code, and if you need any help just let me know:
I don't know how experienced you are with Assembly, so telling me is a good start to see how detailed I must be on what you need to do but there's the code.
Try looking into the Linux kernel and the Ubuntu source code. This will allow you to see more in-depth of how an operating system is structured. Linux-based OS's are relatively small, therefore, will not take as long to develop.
Don't use C (or C++) for what can be done with the shell:
dd of=/dev/fd0 if=./boot bs=512 count=1
I definitely recommend reading sources of Minix. It is very simple and well structured. Linux is too large and bloated to be a good resource for learning.
Remember, you're using a floppy disk to boot the drive to you said.
I said I am using a floppy drive image... I don't have a floppy drive. VMWare uses .flp files and loads it to the virtual floppy drive of the virtual machine, any idea how to create that .flp file?
Try looking into the Linux kernel and the Ubuntu source code. This will allow you to see more in-depth of how an operating system is structured. Linux-based OS's are relatively small, therefore, will not take as long to develop.
Man I have heard that a lot... That's BS. Going straight to writing my own kernel seems easier to me than working my way through thousands of LOC just to understand a monolithic kernel whereas I chose micro-kernel. And besides, if I was building a Linux distribution, I wouldn't call it an Operating System.
Don't use C (or C++) for what can be done with the shell:
dd of=/dev/fd0 if=./boot bs=512 count=1
I see what you mean, but I am not using a hardware floppy drive or disk. So, that is not useful. I guess I mentioned that in the first post of the thread.
I definitely recommend reading sources of Minix.
Yeah, now that's something. You know where to find Minix source code??? It is micro-kernel and small, so it should give me a little understanding before I go on writing something of my own. Linux is definitely not an option (no offense Linux users, I use Linux, too, but the kernel is just too large for me to take in)...