Using Turbo C++

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
TheDragon
Member
Member
Posts: 43
Joined: Mon Aug 25, 2008 8:23 pm
Location: Middle of Nowhere

Using Turbo C++

Post by TheDragon »

Hello. I am trying to build an operating system and I want to know if I can use the Borland Turbo C++ compiler for OS Development. I want to use it because I use the TASM syntax and I don't want to change to AT&T syntax right after I become fluent in Intel ASM. Please help me out. Thanks.
User avatar
cr2
Member
Member
Posts: 162
Joined: Fri Jun 27, 2008 8:05 pm
Location: ND, USA

Re: Using Turbo C++

Post by cr2 »

Well, I'm not sure if you can use Turbo C++, but you can use Visual C++(which uses (I think)the MASM asm syntax, which is pretty close to the TASM syntax).

http://wiki.osdev.org/Visual_Studio
http://www.brokenthorn.com/Resources/OSDevMSVC.html
OS-LUX V0.0
Working on...
Memory management: the Pool
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Using Turbo C++

Post by jal »

TheDragon wrote:Hello. I am trying to build an operating system and I want to know if I can use the Borland Turbo C++ compiler for OS Development. I want to use it because I use the TASM syntax and I don't want to change to AT&T syntax right after I become fluent in Intel ASM. Please help me out. Thanks.
Turbo C++ is a real mode compiler for DOS. So I'd say no, you cannot use it for OS development. As for your concern of Intel vs. AT&T syntax:
1) In most cases, you'll have small(ish) ASM routines you want to call from C. In that case, use a seperate ASM file instead of inlining the ASM, and use nasm instead of gas for compilation. nasm uses Intel syntax just like tasm.
2) Even when inlining, it is possible to use Intel syntax. It's a little cumbersome though, in that for each block of ASM code you'll need to tell the compiler at the start to use Intel syntax, and at the end to use AT&T syntax; that can be solved relatively easy by useing some clever #define-s though. Also, it should theoretically be possible to do without, and to tell GCC to use Intel syntax as well in output, but I have never tried.


JAL
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Using Turbo C++

Post by Combuster »

Turbo C is a compiler for real mode applications.
Almost all other compilers are for protected mode.

And you don't need to use GAS with its ugly syntax - nasm or yasm will do (beware with masm: it has a controversial license effectively denying you to use it for OS development)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Using Turbo C++

Post by i586coder »

your question is nearly my previous question in post:
returned value from custom interrupt

anyway, you can use TC++ to build your OS like my UNEXT/os
its completely written under real mode compiler (TC++3.1)with some cool code
to access all memory using flat-mode trick

guy's suggest me to use:

Code: Select all

-masm=intel
in gcc compiler command line,and gcc can handle INTEL op-code

but most OS projects prefer using gcc,because it's protected mode
compiler ,and give your OS the power instead of FLAT-mode,
Finaly, it's your choice to select your compiler
:wink:
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Re: Using Turbo C++

Post by codemastersnake »

TheDragon wrote:Hello. I am trying to build an operating system and I want to know if I can use the Borland Turbo C++ compiler for OS Development. I want to use it because I use the TASM syntax and I don't want to change to AT&T syntax right after I become fluent in Intel ASM. Please help me out. Thanks.

Yes you can very well write an OS using Turbo C++ 3.0. I used it wto develope 'nOS' when I was in 11th grade. The only problem you'll face is that you'll only be able to write a 16bit Kernel. To write a 32bit kernel you'll have to shift to other compiler like gcc.
User avatar
TheDragon
Member
Member
Posts: 43
Joined: Mon Aug 25, 2008 8:23 pm
Location: Middle of Nowhere

Re: Using Turbo C++

Post by TheDragon »

Thank you SO much for the help thus far. Now I have more questions:
1) Can't Turbo C++ 5 do 32 bit? I'm planning on using it or the newest free IDE (2006). Could it also do 64 bit? It'd be nice to encourage the CPU Manufacturers to
hurry up on advancing past 32 bit processors :D .

2) How would I use NASM separately? Would I compile it into DLLs first? Wouldn't it all be faster if I compiled it all at once?

3) Can I even USE DLLs? Or do I have to write the code to run them too? (Please say and mean no [-o< )
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Using Turbo C++

Post by Combuster »

First hit on google for Turbo C++ 5.0:
I am using Turbo C++ 5, which doesnot allow me to use "namespace std" etc.
:shock: Some further investigation showed that the thing officially isn't called Turbo C++ at that version...
For the rest, Borland C++ 5.x seems to be indeed a 32-bit compiler, but for the rest I don't know how its compiling and linking mechanisms work (I did find that it got some nasty compiler bugs). Given that, I would seriously recommend GCC.

As for NASM: many projects consist of more than one file - each file is compiled in turn, and then in the end everything is linked together. So instead of having just a C-only project, you have a project with C and ASM files. That means you don't need DLLs (which would give you trouble anyways)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Re: Using Turbo C++

Post by codemastersnake »

TheDragon wrote:Thank you SO much for the help thus far. Now I have more questions:
1) Can't Turbo C++ 5 do 32 bit? I'm planning on using it or the newest free IDE (2006). Could it also do 64 bit? It'd be nice to encourage the CPU Manufacturers to
hurry up on advancing past 32 bit processors :D .

2) How would I use NASM separately? Would I compile it into DLLs first? Wouldn't it all be faster if I compiled it all at once?

3) Can I even USE DLLs? Or do I have to write the code to run them too? (Please say and mean no [-o< )
I would really suggest you that you should shift to gcc/ld/nasm environment for your os development. This is because you'll able to find out support for all the errors, bugs you encounter during development, here.
User avatar
TheDragon
Member
Member
Posts: 43
Joined: Mon Aug 25, 2008 8:23 pm
Location: Middle of Nowhere

Re: Using Turbo C++

Post by TheDragon »

So what you're saying that I like compile the NASM sources into an object file, and then compile and link them all with GCC. Right?
Oh, BTW, if I can do something like that, I'd plan on using Dev-C++ or something like that.
But can I use DLLs?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Using Turbo C++

Post by Combuster »

TheDragon wrote:can I use DLLs?
Yes you can use DLLs. But you're probably asking the wrong question here.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
i586coder
Member
Member
Posts: 143
Joined: Sat Sep 20, 2008 6:43 am

Re: Using Turbo C++

Post by i586coder »

TheDragon wrote: Can't Turbo C++ 5 do 32 bit? I'm planning on using it or the newest free IDE (2006)
TC 5 is win32 Compiler,that mean
- TC 5 generate PE(protable executable) image
- Use windows API

if you use such compiler you need to:
- load PE image from your boot loader
- shut all external API (I think it's the very hard part,cause win32 application depend on windows 99.9%)
Snake wrote: I would really suggest you that you should shift to gcc/ld/nasm environment for your os development
I think he is right 8)
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Re: Using Turbo C++

Post by codemastersnake »

TheDragon wrote:So what you're saying that I like compile the NASM sources into an object file, and then compile and link them all with GCC. Right?
Ans: Exactly!
TheDragon wrote:Oh, BTW, if I can do something like that, I'd plan on using Dev-C++ or something like that.
But can I use DLLs?
I doubt :|
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Using Turbo C++

Post by ru2aqare »

AhmadTayseerDajani wrote:
TheDragon wrote: Can't Turbo C++ 5 do 32 bit? I'm planning on using it or the newest free IDE (2006)
TC 5 is win32 Compiler,that mean
- TC 5 generate PE(protable executable) image
- Use windows API

if you use such compiler you need to:
- load PE image from your boot loader
- shut all external API (I think it's the very hard part,cause win32 application depend on windows 99.9%)
Yes, you will probably need to implement PE support in your boot loader, but I would argue with the other point (that it's hard to do). You can write code that doesn't depend on any Windows API even with MSVC (I compile the 32-bit and 64-bit portions of my boot loader with MSVC, so it is definitely possible). So you should be able to do it with Turbo C either.

However, since most people here seem to use GCC, if you want others to compile your code with minimum hassle, you should switch over to GCC.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Using Turbo C++

Post by AJ »

TheDragon wrote:But can I use DLLs?
I know you've had a couple of answers relating to this already, but perhaps you need to think what happens when you use a DLL (or SO).

Your OS will (probably) consist of a kernel (+- modules) loaded in to memory by a boot loader. When you try to use a DLL, your host environment usually takes care of loading and linking with the DLL.

Now, because you are in an unhosted environment, your kernel will need to perform the dynamic loading and linking. This means that any disk drivers to access the DLL must be either loaded by the boot loader, or must be statically linked with your kernel. In addition, the dynamic linker itself MUST be statically linked (think about it ;) ).

All of the above means that while you can use DLL's, you won't actually be using them until you have a few other things in place.

Cheers,
Adam
Post Reply