Page 1 of 1
Hole OS In C/C++
Posted: Sun May 20, 2001 10:14 am
by Ricky
I am new to C/C++ and I will be taking a class in C++ next year ( Computer AP class in High School). Right now I am a very advanced Visual Basic programmer working on very technical programs, but I have always had a love on VERY technical projects (OS, Compiler/Interpreter) but I never had the skills, in an advanced language, but I hope to one day...!
My main question is: Can you write an entire OS in C++, I know what some compilers allow you to insert ASM code (like this, ASM('code'); ) but I figured that if you write a C++ program in Windowz or Linux that it would only be compatible with that operating system... Is that true?
Thank you very much
~Chilly
Re: Hole OS In C/C++
Posted: Sun May 20, 2001 12:51 pm
by df
yes you can write it in C++, but remember, you dont have the support libraries to take for granted (new, etc), so you have to write an implementation of 'new'. Other things like RTTI (run time type information) and things.
Re: Hole OS In C/C++
Posted: Mon May 21, 2001 2:07 pm
by Ricky
Ok, but i don't understand all this stuff...i mean i understand the basics but i really do know how to write my own printf(); routine or any of the file in/out stuff.... i figured once i had that working i could have a text based OS for a while and then move on to putting colored pixels on the screen....i know it is much harder than this but, in Visual Basic you can see what is available for you to use, and you can build stuff, but i dont understand how to write my own low level functions.
~Chilly
Re: Hole OS In C/C++
Posted: Mon May 21, 2001 9:00 pm
by osteron
You can write most of an OS in C++, however stuff like the bootloader and the IRQ handling functions have to be in assembly.
If you are unsure even how to begin, probably best to look at some existing source code, possibly an early copy of the linux kernel to see what's involved.
Also have a check at this URL:
http://www.acm.uiuc.edu/sigops/roll_your_own/
hth,
osteron
Re: Hole OS In C/C++
Posted: Wed May 23, 2001 12:38 am
by Ricky Chilcott
What do you is the best C compiler and ASM compiler for OS development. As of now im running windows 98 so i need something to run on that, but i should be getting a laptop soon with some Linux Distro on it... Which distro is good for os development?
~Chilly
Re: Hole OS In C/C++
Posted: Wed May 23, 2001 9:48 am
by Alexei A. Frounze
What do you is the best C compiler and ASM compiler for OS development. ? As of now im running windows 98 so i need something to run on that, but i should be getting a laptop soon with some Linux Distro on it... ?Which distro is good for os development?
~Chilly
I think it doesn't matter. All you need is gcc, g++. Any OS that has port of the two would be OK. You may even do some stuff under dos/win9x/me/nt/2000 because there is a dos port of gcc and g++, namely djgpp. There are others like cygwin, mingw, etc which are good if you do that under win32.
Re: Hole OS In C/C++
Posted: Mon Jul 23, 2001 8:39 am
by BLoggins02
Well if you want to be a purist then Debian/GNU is the best distro, partly because it's the "generic" distribution (i.e. non commercialized). ?It's also the hardest to learn, there aren't a lot of pretty setup screens, dancing penguins, or automatic wizards that do everything for you or hold your hand. ?That said, it's probably best because it forces you to LEARN the operating system. ?However, if you just want a nice 32-bit environment to write your own OS and don't care about also learning the ins and outs of Linux, just run RedHat. ?It's simpler to set up then Debian but isn't as inane as Mandrake. ?Mandrake is fine but it has a habit of not automatically installing some things that you obviously will need (e.g. Mandrake doesn't install a telnet client even when you select LAN WORKSTATION !!!! Retarded.). ?You won't find out you don't have something until you need the package but you can't get it because you leant the CD out to a friend and you're on a 28.8K internet connection and the package is 5 billion megs, you get the idea. ?This is probably a little unfair but I've learned when it comes to Linux, standardized is better. ?If you're developing an OS, go with RedHat or Debian/GNU. Period.
Also, for the love of all that is holy DON'T use gas (the GNU Assembler) if you're just starting out and used to NASM, TASM, MASM, a86, whatever... ?gas uses AT&T syntax and if you're used to Intel syntax you WILL pull your hair out while you first figure out how to read it, then how to write it, then tracking down a system crashed because you did movb %al, %bl instead of movb %bl, %al. ?Do yourself a favor and download NASM for Linux.
Of course, if you want to learn the AT&T syntax and all the little idiosyncracies of gas, feel free. ?I just think it steepens the learning curve and when you're writing an OS it's easy to feel overwhelmed and just quit.
Just my .02
Re: Hole OS In C/C++
Posted: Sun Aug 05, 2001 1:30 am
by VLAVI
About GAS... it comes with GCC so you dont need look after other compiler. The AT&T syntax is just different from the INTEL syntax not worst, and if you want to put embedded assembler code with GCC, you HAVE TO know AT&T systax (gcc uses GAS).
...just other thing: doesn't NASM use AT&T sysntax too?
(It's obvious that i like GAS?
)
Re: Hole OS In C/C++
Posted: Sun Aug 05, 2001 9:06 am
by BLoggins02
No, NASM does not use AT&T syntax, it uses a cleaner (less complicated) form of Intel syntax. And I don't have a problem with GAS, on the contrary I think it's very powerful and I'm sure if you've never seen assembler before then you would be well advised to learn on it if you're going to be working with GCC. However, as I said, if you already are familiar with TASM, MASM, Intel syntax then you would be best to stick with NASM in the early stages, as the different syntax will just frustrate you and cause bugs to creep in because somethings you do (like reversing src and dst operands) won't be caught by the assembler as an error most of the time.