I am learnig asm at this time. Do you know how much should I learn asm and then start writting my own os. I want to work more with C\C++ than asm.
Printable View
I am learnig asm at this time. Do you know how much should I learn asm and then start writting my own os. I want to work more with C\C++ than asm.
I'll put it to you this way, If your going to be learning on your own, your better off KNOWING assembly. TRUST ME ON THIS!!!
Makeing a Bootstrap is not the easiest thing in the world in C/C++... Also, you would need to make sure you create RAW BIN files and it's tough to do in C/C++. UNLESS you know how to do it. I don't.
I know assembly, so makeing the OS in ASM is much easier to me.
Knight
Knight, have you ever written your own os? I tried but the only info i could find was on bootstraps, so i never get past that. I would love to write a small one with basic features just to learn.
Funny you ask that.. Yes, I am in the middle of my own OS. In fact, if you goto not only my website, but www.stengineer.com you will see that a bunch of us are making a WHOLE new computer based off of my OS. It's called LOS, or LCARS Operating System. You know those panels you see on Star Trek? Well, LOS is based off of that look and feel. We have PDFs and Manuals written up on the subject. We are working toward the same goal. To have a computer that will plug into the net but with beauty and style.. LOL
So in answer to your question, YES, I am making my OWN OS.. ;)
In fact, on my website, if you download BOTH of my BOOTSTRAPS 1 and 2, you can then compile both of them. The first one just sets up for the boot-signature. The second file is called by the first and then executed. It's a simple interface, but it will give you something to play with if you need. The LCARS OS however, will NOT have that interface. It's not been released to the public yet.
You can get a windows version of what it will look like at www.stengineer.com though. STEngineer owns the site, I used to be a part of LCARS Technology, but I decided to branch out on my own.. I hope this answers your question..
Hey guys
I must say don't we all want to write our own O/S's i to have started out on the epic journey of writing my own OS.
Here's some info you may find usefull
1. http://www.nondot.org/sabre/os/articles a bloody good website that covers almost everything on O/S's a very good starting point.
2. Operating Systems... ISBN 0-13-638677-b this book covers the basics of operating systems and uses examples from minix. This book is recommended by most people when starting to leran about or write OS's.
I been to that site many times. I use it like a bible. However, if you want to create a GOOD OS you have to create it in NASM first. Then you can port over to C or create your own C compiler. I know its a lot of work, but if you want your OS to be good, you have to do this. That is the one thing that site doesn't show you. I had to figure out all of this on my own. ALSO there are mistakes at that site. For example, it says in one tutorial that the starting memory address is 7C00:000 while another one says it's 0000:7C000 and still another one says 0000:07C0. So wich is it? Well, after some research I found that it's 0000:07C0. But unless you had someone to show you, you would have not known and your code would end up buggy.
Like I said, it's a greate site, but watch out for the errors.
Yes, it''s a good site but I need a web site that teaches you how to make a "hello world!" OS. and then it start with the mouse support and other ****...
If you goto my site, I have a BOOTSTRAP tutorial 2 I think it is called, that will boot up with a message. Then it hangs. You can just change the string to "Hello World!" if you want.. LOL
Either way, it works. ALSO, I JUST added some really neat routines to my site to make your life a lot easier. Things from PRINT to LOCATE.. Just like in BASIC. :)
The mouse support is not done yet. I have source code on my site for a Mouse driver, but it's still buggy. You can compile it and even try to move your mouse in a program. But your computer will hang do to a stack overflow. It will force you to reboot. However, once I solve this glitch, it will be a fully functional mouse driver that can be ported over to any OS.
I hope my info here helps you out.. :)
I just checked your site out and I really like the way you typed the code (lots of commentsLD)
Thanks a lot but just one question:
How much you write your code in asm and then write everything else in C\C++?
This is the way i'm doing it. I am writting the foundation of the OS in Assembly. That's everything from the bootstrap, to the FAT table. Once those two are done, I am working on my own compiler. This compiler will be in BASIC first. Then I will make sure it can handle ANSI-C code. I'm not going the C++ route.
Eitherway, my interface will be simple to create. All that really needs to be done is the actual code behind it if you ever write software for my OS.
I beleive in the KISS method.. "Keep It Simple Stupid"
:)
Knight Vision, do you remember CTOS? I am implementing FAT and EXT2 into it. I need memory management and kernel... I got multi-threading as well.
I wholeheartedly agree :)Quote:
Originally posted by Knight_Vision
Then I will make sure it can handle ANSI-C code. I'm not going the C++ route.
C is much easier to write so that it coexists with asm code :) Less junk inserted by the compiler :D
Warmaster199 - Hell yea, I remember you son.. How you been man? I have loved making an OS. So yours is going good? Just need a Kernal ehh? Yea, I know the feeling. You do know how to branch into upper memory corrrect? If so, then it's a matter of splicing the time of what each program will need so that you can multi-task it. Remember, EXEs in DOS are setup so that the EXE can tell the OS how many 64K segments are going to be needed. Think of an EXE as a multitasker. (I know it's not). But it jumps from one segment to another and almost simultaniously. Ok, now make a Kernal that can handle Multiple segments at once. In otherwords, think simple.
I know I know... Don't hit me.. LOL I try to explain and I sound like a lot of hot air.. but you know.. It sounds good in theory at least.. LOL
Hang on...there's just one thing here I don't quite get.
If he's writing an OS, why does he need to implement segment:offset handling? Surely it would be better to kick the CPU into protected mode and then work from there?
I don't quite get protected mode... I need to do some research on that, but I do know that it's needed if I am to make the kernel 32-bit - And I am definitely going to have a 32-bit kernel!!! This thing is, I need a protected mode handler to be integrated into the kernel itself. I don't know how to do that, but I do know that I will be using Assembler for that - definitely. ASM is fast, small(compile size, HUGE amounts of code to do simple things), and is best for talking to the hardware. You probably think "This guy's nuts!", but I know what I am doing.
I do want to be able to run DOS executables using CTOS, so I'll need to organize the segments, like you said, Knight_Vision. I've got the source code to a DOS imitation called DOS-C and based on that info, I'll be able to set up the EXE header and such. I got the multitasking part ready... But right now, I gtg, cya
Ok, Knight_Vision, I got the Pre-Emptive multi-tasker code now! That's basically the core of the kernel. I just need a keyboard handler(I got the mouse covered - serial mice), need to check the FAT filesystem out, need segmenting and then, for the most part, I am finished the kernel.
The multi-tasker runs each thread for a clock tick on the timer. 18.2 clock ticks = 1 second. If also has support for "critical sections". These are good, because they can pause the tasker so that the current thread has all of the CPU's power. I got messaging as well: threads can send messages to eachother. Sort of like windows' SendMsg() API call.
I'm not an OS developer, or even an asm programmer, but I just don't understand why you're coding segments? :confused:
It's so that my OS will be able to run DOS programs. Sure, alot of them use the Int 21h vector, I'll need to emulate that as well.Quote:
Originally posted by parksie
I'm not an OS developer, or even an asm programmer, but I just don't understand why you're coding segments? :confused:
Ah. So your OS's memory model is flat by standard, but can run an emulation thread that interprets segments? :)
Yes, but that has to be incorporated into the code. Actually, If I wanted it to, it wouldn't have to use a thread. I'd put it in the kernel and if something really has to be done, I could put it in a critical section in the tasker. :cool:
:cool:
I understand now, thanks :)
Any time! :cool:
Ha! About the beginning topic of this thread;Quote:
Originally posted by abdul
I am learnig asm at this time. Do you know how much should I learn asm and then start writting my own os. I want to work more with C\C++ than asm.
C/C++ are very good languages. ASM is good too, but mainly because it's the fastest running language running. A good thing about C/C++ is that you can incorporate ASM into it.
My advice is:
Learn C/C++ first to establish programming fundamentals and syntax. After that, start learning Assembly(ASM). I am just starting ASM, myself. It seems complex, but my background in other programming languages helps SIGNIFICANTLY.
It is VERY good if you comment. The analogy my teachers have told me is "Comment all of your code. That way, if you come back to it in a few months, you know exactly what's going on.". Also, if you plan to have a team of friends help you, it's good to comment as it helps them understand what you're trying to do.
C: /* This is a comment */
C++: // This is a comment
ASM: ; This is a comment
Just out of completeness, /* */ is a valid C++ comment as well :)
Also, if you want to quickly exclude a large volume of code which may contain embedded /* */ comments, use this:This prevents nested comments, and the compiler will ignore everything up to the next #endif :)Code:#if 0
int func(void) {
/* This is a comment */
return 5;
}
#endif
I dont think thats an analogy, just good advice.Quote:
Originally posted by Warmaster199
The analogy my teachers have told me is "Comment all of your code. That way, if you come back to it in a few months, you know exactly what's going on."
/* */ Isnt a valid c comment. At least not really. Its probably in some c compilers though. I made that mistake before too.Quote:
Originally posted by Warmaster199
C: /* This is a comment */
An empty comment is invalid? Hmmm didn't know that one :)
No i meant using /* and */ for comments in c is invalid.
/* Comments */ is for ANSI C.Quote:
Originally posted by ChimpFace9000
No i meant using /* and */ for comments in c is invalid.
// is for ANSI C++.
Some C/C++ compiler only allows these, according to your source code file extension. (*.c or *.cpp)
Oh yeah, your right, i had them backwards. I knew one of them wasnt valid for c. Thanks.
C: /* */
C++: /* */
C++: //
That's the way the standards go ;)
Can't you just do make it with GCC? ( http://www.DJGPP.com - Click on Zip Picker). With GCC, you can include a VERY large amount of assembler. Many operating systems such as LINUX, SKYOS, Several other versions of UNIX, and even CTOS(My OS) made compiled with GCC(Gnu C Compiler - It also does C++!)Quote:
Originally posted by Knight_Vision
...However, if you want to create a GOOD OS you have to create it in NASM first. Then you can port over to C or create your own C compiler. I know its a lot of work, but if you want your OS to be good, you have to do this.
Okay, Check the attachment I sent... It's the CTOS boot sector and it comes with partcopy, so you can put it on a floppy... View the Readme file...
Hey guy, you said in a message up there earier that you got the serial mouse to work in your OS? Is this true? And HOW did you do it? I have source code on how to talk to the PS/2 Port mouse, but my code is buggy, and I have had it for everyone to get, but no one has taken it and fixed it for me. Got any ideas on this? I cannot figure out where I went wrong.. I think I am seeing stars.. LOL
Here is my problem, my OS is on hold because I NEED the mouse to work for the OS to work. But since I can't get the mouse to work, i'm screwed... HEEEELLLPPPP!!!!
:)
Sorry, this is frustrating...
Ahhh... I am good! The driver is actually a simple C source. Simple in deed. All you have to do is constantly communicate with the mouse(Outputting / Inputting different ports) and get it to update certain variables... Then use the variables that you modify as the location for your cursor! It is so simple that you will hit yourself(I did when I saw it) once you figure it out... here: straight from CTOS. There are actually 2 files in the zip... mouse.c(the driver) and system.h. The code is messy, but CTOS isn't finished yet :(
This will be helpful :cool: :
This is off topic but Warmaster199 your signature totally sucks.
Warmaster - Thanks budd. I'll look at it when I get home.
Chimpface - You ok guy? You been really negative lately. First you dis BASIC, then you talk negativly about Warmaster's Sig.. What gives? It's not like you. You ok?
Don't get me wrong, I agree that he needs to change his sig, but it is HIS sig. So what should it matter to us what he does with it as long as it's within the rules of ettiquete.
Either way you feel, I hope things are ok for you...
Later
I know... A friend was making fun of Windows and said that to me and it stuck... Ah well... I think it's kind of lame as well... How's this?...Quote:
Originally posted by ChimpFace9000
This is off topic but Warmaster199 your signature totally sucks.
There's no change :confused:
No change??? What? Change in what? Nevermind...
Ok my mistake I read it before you'd changed it :p
Hey Warmaster199, I just checked out your bootstrap ZIP file. I looked at the code and all the comments in it. Don't forget to credit me for the turorial bootstrap that you obviously used in it ok guy? I mean hey, it's not everyday that I see my work in someone else's code.. LOL
On another note, I am sitting here trying to peace together CTOS. And for the life of me, I don't have all the peaces it seems. I have a bunch of icons and BMPs that your text files say will utilize it. I have the boot.bin (ASM file) that you altered from my bootstrap tutorial 1, and I have a mouse.c file. I looked it iver, I cannot figure out how to get it to work with your boot.bin file. I wanted to see your OS working with full mouse support. Is it ready yet? And can I have the source? I wanted to add something to it that I think you might like. LCARS. I wanted to see your work combined with mine.
Let me know what you think. I'm anxous to find out what your response if here..
It is possible, but I haven't compiled it yet. It's just a whole mess of code. Individual parts work, but the thing has not been tested as a whole. I couldn't get GCC to work. As for that bootstrap file... It has changed a bit. It is supposed to load the start-up code which initializes 32-bit protected mode, loads the kernel, and then jumps to the kernel's address.
Right now, I don't think that I should open source it. I am planning to start a company in the future, and probably sell CTOS, as well as games and utilities for CTOS and Windows and such. And of course... No one except me has all of CTOS's code. There is about 3MBytes of PURE TYPED C CODE(with some ASM)!!!
The bootstrap file is actually quite simple now that I think about it. The only tutorial that I used was, I believe, your second one??? It just prints a message... Now the bootstrap prints the start message, sets up the BPB, DPB, and opens the next sector on the disk(startup code). I will put your name in the comment for the boot code... But right now, I really got to go(In a hurry)
Well then could you do me one BIG favor then? I'll credit you for your work in my OS as well. I need a SIMPLE bootstrap that turns the mouse on and I can move the mouse around. Can you do that at least for me?
Thanks guy.
Knight Vision
That is ok. I do not need credit for your OS.
That code is in C. Isn't your OS in PURE assembler? You can't put C in assembler, but you can put ASM in C code. You need GNU C Compiler(GCC) for that code. To make it work, you need a put pixel function, and a set pixel function. Then, you need to call the mouseinterrupt function in that file every time you want to update the cursor and draw the mouse. The mouseinterrupt function automatically calls functions to copy the background, and draw the picture. When you do the mouse interrupt again, it places the previous background back in it's place(Clears the mouse cursor away), gets the next background where the mouse is to be drawn, then draws the pictures. It does that everytime you call it. This is basically what a mouse driver does, so you can call the file I gave you a mouse driver. The thing is, your OS will have to get a little more complicated. You will have to access the disk to load another cluster or two for more code space. There's actually some good tutorials for this on that www.nondot.org site.
Try to convert that code to assembler(Might be hard, but it'll be easier for you to implement because your code is assembler, right?)
I went and got the GNU C compiler. If you send me the whole working code from bootstrap to mouse I'll compile it. Also, could you add the compiled BIN to the ZIP as well? That way I can see what it does BEFORE I compile the code on my end? In that way, i'll know if I compiled it wrong or something.
Thanks for your help. My code is in Pure assembler, but i'll port it over to C if I can just get the mouse going.
Hey i have been reading all these posts and I am really getting interested in this OS creating. I have been wanting to know how it is structured and how to go about it for a long time. Right now all I know as far as programming is VB and very little C++. How do you program assembly. Could you give me some tips. Please email me
Jayman
Thanks
Jayman
Start with reading the FAQ here.
I would be more interested where I can find information on how an OS must be structured etc. Simply how to create a very simple OS (say just a prompt where the only working thing is an echo instruction).
I could make a simple command line like that in a maximum of 50 lines(C/C++).
I have basically done that, but in graphics mode(You need your own font!). All it does is get your input, then draw the corresponding font character on the screen in the specified area(It confines it like it's drawing to a window of some sort)
Here is what I was talking about above, but it's got a window drawn behind it and stuff some it looks good. It's 671 lines of C code(NOT INCLUDED - Classified CTOS System Console code). This is a lame start to what the real CTOS console will look like... With about 30 or so more lines I could use pointers and be independent of that BGI file included, but I'm a little lazy right now that it requires making offsets and stuff because 640x480x16 color is a 4-bit mode. I could do it in 320x240x256 in about 15 more lines, but this is just a simple test.
Description of CTOS windows: There are 2 different titlebars, each of which have an active and non-active (zorders taken into account). The small buttons in the top left of the windows are as follows: A blue triangle facing left for minimizing to the taskbar which is on the LEFT side on CTOS, A pin button(black) to pin/unpin the window to/from the VDesktop(Pin makes window follow desktop, un-pin makes window follow screen), a Maximize button(Full screen - black symbol), and a window close button(a red 'X')
Please check the following file: Extract into any directory, run constest.exe. Type and see what happens. Press [ESC] to quit.
That's cool. Where did you learn to make such things?
If you want to learn about OS structure a good book is
Operating Systems, Design and Implementation
ISBN:- 0-13-638677-6
Where did I learn it? A few documents for the fonts, on the net but that's it. The docu's are just something I came across. Everything else is just my programming skill :). If only I knew enough assembler to do that in it...Quote:
Originally posted by CornedBee
That's cool. Where did you learn to make such things?
I actually mean where did you learn to write e.g. the OS loader? The "classified" part :)
Anything on the net? I'm interested, but not that interested that I would buy a book.
But you're writing an OS and therefore you must somewhere have learned how to do it.
All it is is different numbers and address locations and signals. For the low-down stuff like outportb and inportb(Output and input to ports respectively), I found those in a file that comes with DJGPP the GNU C Compiler. Those are useful for writing / getting values from different ports on your computer whether it's a hard disk and a sound card. Alot of that information can be found on the links to sites that are given in this thread. A really good site for learning drawing algorythms is http://www.brackeen.com/home/vga
There you will find setting modes, drawing pixels, drawing lines, circles, etc... Another good site for finding information on the VESA video modes is http://www.VESA.org
Basically, the information your need is just port values and the meaning of information that you send to the ports.
I can crash the contest project when I press backspace about 100 times...
I see... I've got to fix that. But right now, I am almost finished adding IDE Hard Disk support. The code allows for up to 4 hard disk controllers, which means that you can have 8 IDE drives. Imagine 8x 100GByte drives... The problem is that my code MAY only support up to 8GBytes. I'll look into it later on today. As for that error you found, I know what the bug is, I'll fix it later when I start working on the GUI again (At least I'll make an effort to fix my bugs, unlike Microsoft :) )
are there any commands for the console or just typing?
I coded that in about 30-45 minutes. I didn't include any commands yet, but I will AFTER I get the GUI running(Ability to move windows with the mouse, click buttons...). Most of that coding time is thinking on how to draw a good window and figuring out a way to use my font array.
To answer your question: No commands are supported yet. Why is everyone making such a big deal of this little thing? :D :rolleyes: I was just a simple report on what the O.S. will look like... Oh well :p
Ok, I gtg 2 school now (BTW, my programming teacher says that that console is amazing. Some of the code in there she didn't understand...)
it does look cool, a little too much like windows but cool.