Page 1 of 2
Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 7:39 am
by Silverhawk
Hi !
Is it possible to develop and to compile an OS under Visual Studio ?
I don't know how to do ! I didn't manage to indicate a binary output format...
It would be fine if someone could explain me the different step...
(I want to use the MS Visual Studio, beause I don't like le AT&T inline assembler of GCC...)
Thanks a lot ! ::)
Re:Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 7:49 am
by Robert Lee
I also hate the AT&T syntax used by most C compilers.
Unfortunatly AFAIK Visual C++ 2.0 and higher can not be used to create executables for anything other then windows (or another supported platform such as WinCE, if support is installed).
One of the reasons I don't use C at all is that there are no good compilers out there with support for a decent assembler. I use TASM as my assembler but haven't looked into Borland C. You might try that.
The thing with using C is that you always have to deal with platform-dependant crap being added to your code. And finding hacks to get the compiler to cut it out. And in the end you end up writting your own library anyway.
Don't get me wrong, there are people who swear by C/C++ for OS development! For me, I'm very comfortable working with assembler so that's what I use. Good luck finding a C compiler that will work for you. Who knows, maybe someone here knows a way to get VC++ to output platform-independant code.
Just my $0.02.
-Robert
Re:Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 7:52 am
by Pype.Clicker
if AT&T is your sole reason, then you might like the intel-syntax trick ..
asm (".syntax intel noprefix")
Re:Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 9:33 am
by bkilgore
If you combine Pype's intel syntax trick with a VC++ Makefily project, you can easily get your existing OS to build from VC++ (still uses GCC to compile, which is why you still need the intel syntax trick). Then you get to keep the benefits of an easily reusable makefile, the intel syntax, and MS's syntax coloring (and stuff like visual studio if you use it).
This is the method I use and it works pretty well.
- Brandon
Re:Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 10:19 am
by Schol-R-LEA
Or you could simply code your assembly functions separately and assemble them with the assembler of your choice. But then, I never really cared for inline assembly anyway, so I'm biased...
Re:Compile your own OS with Visual Studio
Posted: Thu Aug 07, 2003 10:25 am
by Tim
Robert Lee wrote:Unfortunatly AFAIK Visual C++ 2.0 and higher can not be used to create executables for anything other then windows (or another supported platform such as WinCE, if support is installed).
No, what you mean is: "Visual C++ can't create anything other than PE executables". It's inconvenient to use VC++ to build a kernel, but not impossible, and certainly not impossible for user-mode apps.
Re:Compile your own OS with Visual Studio
Posted: Fri Aug 08, 2003 12:59 am
by Silverhawk
thanks to you all !
So, I must use :
Pype.Clicker wrote:
if AT&T is your sole reason, then you might like the intel-syntax trick ..
asm (".syntax intel noprefix")
but were ?
in a make file ? Is it what you suggest Brandon ?
bkilgore wrote:
If you combine Pype's intel syntax trick with a VC++ Makefily project, you can easily get your existing OS to build from VC++ (still uses GCC to compile, which is why you still need the intel syntax trick). Then you get to keep the benefits of an easily reusable makefile, the intel syntax, and MS's syntax coloring (and stuff like visual studio if you use it).
This is the method I use and it works pretty well.
- Brandon
Could you explain me that in more details please ?
I'm very interested in your solution !
Re:Compile your own OS with Visual Studio
Posted: Fri Aug 08, 2003 1:29 am
by Pype.Clicker
just issue that asm instruction before any of your inlined asm (it may be in a kind of global.h that will be included first in any C file, or repeated at the top of every .H/.C file that declares some asm("...") stuff ...
Re:Compile your own OS with Visual Studio
Posted: Fri Aug 08, 2003 1:29 am
by Perica
..
Re:Compile your own OS with Visual Studio
Posted: Fri Aug 08, 2003 2:06 am
by Silverhawk
Thanks for those precisions, I will try it this week-end...
Re:Compile your own OS with Visual Studio
Posted: Fri Aug 08, 2003 4:23 am
by Pype.Clicker
@perica: i haven't tryed your macros, but i fear they'll make troubles as soon as commas will be used...
maybe replacing "#define iAsm(x)" by "#define iAsm(x...) " could help
Re:Compile your own OS with Visual Studio
Posted: Sat Aug 09, 2003 3:40 am
by pini
With recent GCC compilers, you can use the following command line parameter :
Code: Select all
gcc #your params here# -masm=intel
to override the default AT&T syntax.
Re:Compile your own OS with Visual Studio
Posted: Sat Aug 09, 2003 6:52 am
by Solar
I think it's pretty funny how people today flame the AT&T syntax... IMHO, that shows you've never programmed anything else but an x86, and never in anything else
but Intel syntax.
Ask people from the good ol' times of 6802 or 680x0 CPUs, or those writing PPC code, or quite a lot others: As with almost everything else, the "Intel way" is quite screwed up, it's just so commonplace that most people accept it as being "right"...
I seriously suggest giving AT&T syntax a try beyond the initial frustration phase. I am very thankful for not having to think "backwards" with every other statement, and the prefixes add explicitness which I consider A Good Thing (tm).
One statement makes my toenails curl:
One of the reasons I don't use C at all is that there are no good compilers out there with support for a decent assembler.
Which means "inline assembler", which also means you don't seperate your assembler from your HLL (high level language), which usually isn't that good a design decision IMHO.
The thing with using C is that you always have to deal with platform-dependant crap being added to your code. And finding hacks to get the compiler to cut it out.
That's not a "hack" but a "command line option". Welcome to kernel space which simply cannot be the default setting to a toolchain by anyone's standards.
And in the end you end up writting your own library anyway.
...or porting it, which is probably the more efficient way. (BTW, anyone knowing a good
Public Domain C lib?)
Somewhere down the road, you have to make the transition from ASM to HLL anyway (unless you want to force your users writing everything in ASM, too). I prefer getting my co-developers into the "comfort zone" as quickly as possible, which means I try to make the ASM-HLL transition as early as feasible.
Who knows, maybe someone here knows a way to get VC++ to output platform-independant code.
The goal of an OS developer is not to
write platform independent code, but to
enable platform independent code (if that is a feature of the OS). At least as I understand it: Your job is hard, so that the job of all others is easy.
Re:Compile your own OS with Visual Studio
Posted: Sat Aug 09, 2003 3:45 pm
by Ozguxxx
Hi, well I think it is pretty cool to use visual c++ for editing os code. Why is it inconvenient? I think with method that bkilgore tells, visual c++ can be used to code a kernel but as far as I could observe you can just use its good editing and source code handling features. Also I got tired of working with notepad maybe a change will be good becuase with vc++ you can set background and foreground colors to something that does not tire your eyes, you know after working with notepad about 3-4 hours of coding, I just start seeing stars and my head aches very badly... I remembered old days of windows programming... ;D BTW, I also donot like inline assembly...
Re:Compile your own OS with Visual Studio
Posted: Sun Aug 10, 2003 2:28 am
by Solar
Ozguxxx wrote:
Also I got tired of working with notepad maybe a change will be good becuase with vc++ you can set background and foreground colors to something that does not tire your eyes, you know after working with notepad about 3-4 hours of coding, I just start seeing stars and my head aches very badly...
I have yet to find any IDE that comes with an editor that suits my needs. AmigaOS' StormC offered integration with GoldED, which is one of the best editors I've ever used.
Editors for Windows:
UltraEdit,
http://www.ultraedit.com - better than TextPad IMHO; crippled Shareware (demo does not save).
TextPad,
http://www.textpad.com - the "standard"; uncrippled Shareware (but remember, software worth using is software worth buying!).
Editor for Windows and Linux:
SciTE,
http://www.scintilla.org/SciTE.html - GPL'ed; the GUI is not as elaborate, but the feature set is quite complete.
Some people also swear on Emacs, but as you see from my list of suggestions, I prefer GUI editors.