I am new and need help please.
I am new and need help please.
Hello all, i'm new at this forum.
I have two questions that I need to have some answers on from some of you guys. So I hope you can help me;
My first programming language I learned was assembly. I only learned bits of it, but enough to understand the basics and intermediate stuff. However, it was long ago (back when I was 15 years old), so I can hardly remember any of it now. I am however relearning the assembly language now.
I have always wanted to construct my own operative system for personal reasons. But I need help. So here are my questions:
1. I have been looking around and I don't know where to start. I have read tons of tutorials on how to begin, but they all are extremely different in many ways. Some tutorials state that you can use C/C++ to code your OS. This is not the case for me however, because my only language is assembly. I am most comfortable with the NASM assembler (Intel Syntax), so am I able to make my OS with that? If not, I have a book called "80x86 Assembly Language and Computer Architecture" that discusses the MASM assembler at great lengths, but to me MASM syntax looks very chaotic, so I would rather not use it... But if I have to do, then I will do it.
2. I understand that the first thing you need to make is a bootloader. You code the bootloader in assembly/C/C++ and compile it to a binary format, whereafter you convert the binary format to an image file so that the BIOS will load it up (once setting bootsectors up, or whatever it's called ). Now my question to this is; It has to be possible to make the image for a CD and not a floppy drive like all the tutorials I have read covers. Is an image file like a .iso or is it something else?..
Okay, so theoretically let's put this up in a step-by-step situation so I can make sure i've understood it (through my own interpretations of tutorials and so forth):
1) I will use the assembly language to build everything essential to my OS, the assembler will be NASM (Netwide Assembler) and will be using Intel syntax (now i've actually put myself in doubt, as I am not sure this matters because NASM has it's own syntax, but whatever... Correct me if i'm wrong please).
2) Code a bootloader in assembly
3) Assemble the assembly code into an object file.
4) Image the object file
5) Put it on a floppy/CD
6) Run it on computer.
Is this right?
Thanks all.
I have two questions that I need to have some answers on from some of you guys. So I hope you can help me;
My first programming language I learned was assembly. I only learned bits of it, but enough to understand the basics and intermediate stuff. However, it was long ago (back when I was 15 years old), so I can hardly remember any of it now. I am however relearning the assembly language now.
I have always wanted to construct my own operative system for personal reasons. But I need help. So here are my questions:
1. I have been looking around and I don't know where to start. I have read tons of tutorials on how to begin, but they all are extremely different in many ways. Some tutorials state that you can use C/C++ to code your OS. This is not the case for me however, because my only language is assembly. I am most comfortable with the NASM assembler (Intel Syntax), so am I able to make my OS with that? If not, I have a book called "80x86 Assembly Language and Computer Architecture" that discusses the MASM assembler at great lengths, but to me MASM syntax looks very chaotic, so I would rather not use it... But if I have to do, then I will do it.
2. I understand that the first thing you need to make is a bootloader. You code the bootloader in assembly/C/C++ and compile it to a binary format, whereafter you convert the binary format to an image file so that the BIOS will load it up (once setting bootsectors up, or whatever it's called ). Now my question to this is; It has to be possible to make the image for a CD and not a floppy drive like all the tutorials I have read covers. Is an image file like a .iso or is it something else?..
Okay, so theoretically let's put this up in a step-by-step situation so I can make sure i've understood it (through my own interpretations of tutorials and so forth):
1) I will use the assembly language to build everything essential to my OS, the assembler will be NASM (Netwide Assembler) and will be using Intel syntax (now i've actually put myself in doubt, as I am not sure this matters because NASM has it's own syntax, but whatever... Correct me if i'm wrong please).
2) Code a bootloader in assembly
3) Assemble the assembly code into an object file.
4) Image the object file
5) Put it on a floppy/CD
6) Run it on computer.
Is this right?
Thanks all.
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: I am new and need help please.
Know it like the back of your hand before you write an OS with it. You should also learn C, because many, many tutorials are written using it.I only learned bits of it
Yes.I am most comfortable with the NASM assembler (Intel Syntax), so am I able to make my OS with that?
You actually can't. The license forbids OS development with MASM.MASM syntax looks very chaotic, so I would rather not use it...
You compile a bootloader into a flat binary file. The extension is irrelevant, but .bin is preferred. You then copy this into your medium of choice. I recommend floppies or hard disks, because they're the simplest. That is what most of the tutorials assume you use.Is an image file like a .iso or is it something else?..
1. NASM uses Intel syntax for instructions, but AFAIK stuff like 'db', 'times', etc. and NASM specific. Be aware that making your OS entirely in assembly isn't going to be easy. If you want to make a fairly simple command line based OS you'll be OK, but if want to get very advanced you'll have issues.1) I will use the assembly language to build everything essential to my OS, the assembler will be NASM (Netwide Assembler) and will be using Intel syntax (now i've actually put myself in doubt, as I am not sure this matters because NASM has it's own syntax, but whatever... Correct me if i'm wrong please).
2) Code a bootloader in assembly
3) Assemble the assembly code into an object file.
4) Image the object file
5) Put it on a floppy/CD
6) Run it on computer.
2. I would actually do this first, and then work on a kernel.
3. Not an object file, a flat binary. The BIOS just loads the first 512 bytes of your code, it doesn't know what an object file is. If you want to put your kernel in a normal executable file, take a look at GRUB. It will load ELF files for you if you want to go that route.
4. If you are using a flat binary, and a flat HD or FD image, just copy your bootloader/kernel onto the beginning of the image. Alternatively, you can directly use your bootloader/kernel binary as your HD or FD image.
5 & 6. Use Bochs or Qemu or another emulator. Testing on RHW is much too slow for early development.
Good luck!
Re: I am new and need help please.
Thanks, that helped me alot.
Now, one last question; How will I know, that I know assembly like the back of my hand? Stupid question, but I feel it's pretty valid... But maybe wrong forum to ask such a thing
EDIT: And I will able to learn everything from reading through the NASM documentation, and then coding my own "little programs", right? (like a calculator, or a calender)
Now, one last question; How will I know, that I know assembly like the back of my hand? Stupid question, but I feel it's pretty valid... But maybe wrong forum to ask such a thing
EDIT: And I will able to learn everything from reading through the NASM documentation, and then coding my own "little programs", right? (like a calculator, or a calender)
Last edited by casualasm on Mon Jan 19, 2009 11:36 am, edited 1 time in total.
Re: I am new and need help please.
[url="http://www.brokenthorn.com/Resources/OSDevIndex.html"]check this tutorial chain[/url] that was the second one i followed when i started, and it helped so much! it goes through making a bootloader in nasm to begin with and then move onto a C kernel. but you can do what you want after that really... the bootloader should keep you busy for a while though
and as for knowing asm off by heart: it will just flow out of your fingers and onto your computer screen.
and as for knowing asm off by heart: it will just flow out of your fingers and onto your computer screen.
Re: I am new and need help please.
Only the boot strap code actually needs to be a flat binary. The main boot code ("OS Loader", or "Stage 2") can be written in a higher level language and does not need to be a flat binary.You compile a bootloader into a flat binary file.
Usually when you can write assembly code without much problems, it becomes easier to work with.Now, one last question; How will I know, that I know assembly like the back of my hand?
Last edited by neon on Mon Jan 19, 2009 11:41 am, edited 1 time in total.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Re: I am new and need help please.
Oh man, that's sick dude... Thank you alot.xDDunce wrote:[url="http://www.brokenthorn.com/Resources/OSDevIndex.html"]check this tutorial chain[/url] that was the second one i followed when i started, and it helped so much!
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: I am new and need help please.
Cliche answer: When you're ready, you will know.
Real Answer: You're going to want to be able to use all of the basic instructions, and you need to be able to write programs that a functional in assembly. You need to understand a lot of it.
-JL
Real Answer: You're going to want to be able to use all of the basic instructions, and you need to be able to write programs that a functional in assembly. You need to understand a lot of it.
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: I am new and need help please.
One thing I don't understand is this; You start out by making a flat binary file (this is the bootloader). After that, you can build the kernel in, for example, C right? So i'd have to compile this C program on another computer and bring it as an .exe to the test computer. But how will it know what .exe is? Since that's a MS Windows extention (like Linux has it's own)... I'm pretty sure i've got it all wrong, but bear with me.neon wrote:Only the boot strap code actually needs to be a flat binary. The main boot code ("OS Loader", or "Stage 2") can be written in a higher level language and does not need to be a flat binary.You compile a bootloader into a flat binary file.
Re: I am new and need help please.
Just have your bootloader dump the EXE file to some location in memory (either physical or the current virtual address space) and have your boot code parse its header info to execute it properly or to get additional information from the file. This applies to (I believe) any executable format.casualasm wrote:But how will it know what .exe is?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: I am new and need help please.
Truthfully, the format doesn't matter as long as you know how to load it. You can use PE (exe), ELF, flat binary, your own format that you invent, or whatever else you find. Typically, people go with flat binary in the early stages (bootloader and second stage) because it's just load it and jump/call, and move on to either PE or ELF (usually ELF around here) in later stages.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: I am new and need help please.
Plus, GRUB easily loads ELF (and I don 't know about others). That way you can skip the bootloader, but writing you own boot loader allows you to know more about the system, but skipping is easier. Thats your decision.
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: I am new and need help please.
Well, i'd like to start from scratch... Skipping something would just ruin the whole experience.piranha wrote:Plus, GRUB easily loads ELF (and I don 't know about others). That way you can skip the bootloader, but writing you own boot loader allows you to know more about the system, but skipping is easier. Thats your decision.
-JL
Re: I am new and need help please.
Your best starting by using bootprog, this is a boot loader written in nasm, that can load a com or mz exe from a floppy.
I know you have not got a floppy, but you can use a floppy image to make a cd bootable.
http://alexfru.chat.ru/epm.html#bootprog
If you want to make your own bootloader than by studying bootprog it will help.
Your best to start off by making some bootable demo's, before moving on to your main OS.
See here for examples: http://forum.osdev.org/viewtopic.php?f=2&t=18763
I know you have not got a floppy, but you can use a floppy image to make a cd bootable.
http://alexfru.chat.ru/epm.html#bootprog
If you want to make your own bootloader than by studying bootprog it will help.
Your best to start off by making some bootable demo's, before moving on to your main OS.
See here for examples: http://forum.osdev.org/viewtopic.php?f=2&t=18763
Re: I am new and need help please.
I actually slightly disagree with some of the previous posters. I also think you should learn a higher level language, which you can do without leaving ASM. I think like the OP that there is no point in skipping a stage of the development process. If I wanted something fast I would make a linux distro. I know the fun stuff is way way way after the bootloader but still I want to look at my OS and know that I programmed every bit of it.
I think that it is not as important to know ASM like the back of your hand as to be able to read it. I can't really program in ASM without trouble but I can look at it and step through the code. likewise I can look at some C or C++ code and break it down far enough to know the basic functions I want then I simple break out my Intel manuals to see what opcode will accomplish the task I need. I did have an excellent ASM reference though, it even covered sytem programming to a degree. I think it was called "The Art of Assembly", here is a link to a website that looks like it has a pdf version for learning 16-bit and 32-bit versions. The only bad part is the pdf's are broken down by chapters. You can also buy the books if you like the pdf's. There is also some information about programming in HLA or High Level Assembly, That is what I was talking about earlier with learning a higher level language for rapid development and not leaving ASM.
I personally think the BrokenThorn.com Tutorials are KING, they don't just through some code at you, infact most of what they have is informaional and it blows away the competition for gaining an understanding of the system and how things work. I wouldn't have any OS if I hadn't found them. I can't wait until the next one is posted. Even though I am moving past where they have left off.
anyway, I say enough ASM is enough I prefer C++ but really any compilable language will do as long as it isn't run-time compile like C#. If you want to do ASM only I would study DexOS, I think it is open-source and ASM, there is also MenuetOS, it's cool and fits on a floppy. you could look at thier code to see how certain things are done.
Well, I think I have talked enough. good luck with your OS
I think that it is not as important to know ASM like the back of your hand as to be able to read it. I can't really program in ASM without trouble but I can look at it and step through the code. likewise I can look at some C or C++ code and break it down far enough to know the basic functions I want then I simple break out my Intel manuals to see what opcode will accomplish the task I need. I did have an excellent ASM reference though, it even covered sytem programming to a degree. I think it was called "The Art of Assembly", here is a link to a website that looks like it has a pdf version for learning 16-bit and 32-bit versions. The only bad part is the pdf's are broken down by chapters. You can also buy the books if you like the pdf's. There is also some information about programming in HLA or High Level Assembly, That is what I was talking about earlier with learning a higher level language for rapid development and not leaving ASM.
I personally think the BrokenThorn.com Tutorials are KING, they don't just through some code at you, infact most of what they have is informaional and it blows away the competition for gaining an understanding of the system and how things work. I wouldn't have any OS if I hadn't found them. I can't wait until the next one is posted. Even though I am moving past where they have left off.
anyway, I say enough ASM is enough I prefer C++ but really any compilable language will do as long as it isn't run-time compile like C#. If you want to do ASM only I would study DexOS, I think it is open-source and ASM, there is also MenuetOS, it's cool and fits on a floppy. you could look at thier code to see how certain things are done.
Well, I think I have talked enough. good luck with your OS
Getting back in the game.
Re: I am new and need help please.
Sometimes you may find it easier to skip the boot stage and use an existing boot loader for now if your beginning requirements are unknown. If you do know if your system requires special boot time requirements, or your requirements require a custom boot loader for some reason, you can always develop one either before or even after the kernel program has been started.
It all depends on what you want the system to do, and the requirements needed for it. Pick an option and stick with it until you are further in your development time line...You can always go back to the boot stage again if you need to.
Oh, and good luck with your OS
It all depends on what you want the system to do, and the requirements needed for it. Pick an option and stick with it until you are further in your development time line...You can always go back to the boot stage again if you need to.
Oh, and good luck with your OS
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}