Converting Turbo C for MS DOS to Windows

Sac Arrow

Touchdown! Greaser!
PoA Supporter
Joined
May 11, 2010
Messages
20,643
Location
Charlotte, NC
Display Name

Display name:
Snorting his way across the USA
Okay so I have an engineering program that runs under MS DOS with graphics and data entry screens all hard coded in Turbo C. Is there any way to convert it in to a Windows application without rewriting the entire thing? I realize that graphics, data entry and file handling will be new but it would sure put me out rewriting the computational routines.

No I am not a Windows developer nor do I presently have the tools. My programming experience ended at pre-Windows C, Fortran and Basic.
 
Aww geez.

Had to do that myself. Just run it in a DOS window.

--

Actually, if you have the functions you need, you can cut and paste them into a module for whatever language you are using. But you'll have to verify the functions aren't calling any specific TC library functions, you'll have to change those to call whatever library functions your new system provides. You might end up having to use the existing code as a template/algorithm and rewrite for your new compiler. It can get pretty detailed.

Porting stuff like this is a PITA, but doable. If I can do it, pretty much anybody can. Sounds to me like you won't be doing this yourself? Whoever does it for you needs to be aware of what the old application did, how, and why. That will help tremendously when they try to import it into a new version. Hopefully the original is well commented.
 
Last edited:
freeze dried or doing hard time?

The numerical stuff should compile just fine. I'd package it into a dll (or modern equivalent) and then front end it with Excel or Open Office for graphics and file handling...

Of course I haven't actually done that in five or six years so am not up to date on what might be practical now.
 
Have you tried running the program in the DOS box with Windows 8 or 7? You might be pleasantly surprised. I've written some very hardware-intensive programs in MASM and had them run perfectly in the 7.1 DOS box.

If that doesn't work...

Get it running in the DOS box in XP and then run the XP instance as a virtual machine under whatever later version of windows you're running.
 
Have you tried running the program in the DOS box with Windows 8 or 7? You might be pleasantly surprised. I've written some very hardware-intensive programs in MASM and had them run perfectly in the 7.1 DOS box.

If that doesn't work...

Get it running in the DOS box in XP and then run the XP instance as a virtual machine under whatever later version of windows you're running.

Yep, we are still running dbase IV that way for a system written 30 years ago. :)
 
Yes of course I can run it in a DOS window using Dosbox and it runs fine, I just wanted to modernize it, e.g. Windows file management, resizeable graphics, etc...

Also recompiling the source for changes isn't an option. The compiler software and outdated hardware are long gone.
 
Yes of course I can run it in a DOS window using Dosbox and it runs fine, I just wanted to modernize it, e.g. Windows file management, resizeable graphics, etc...

Also recompiling the source for changes isn't an option. The compiler software and outdated hardware are long gone.


Did the program in question ever have 'windows file management, resizeable graphics, etc'?

If it did, and you have the original source code, it could probably be recompiled with a modern compiler, although I'm sure there would be some level of effort to update the source itself to compile in the 21st century, but it might not be a huge task.

If the original source code didn't do that stuff then really you'll need a Windows developer to take that source code and then use it as the basis of a new Windows application. That's certainly doable, but there would be a significant level of effort involved.
 
Yes of course I can run it in a DOS window using Dosbox and it runs fine, I just wanted to modernize it, e.g. Windows file management, resizeable graphics, etc...

Also recompiling the source for changes isn't an option. The compiler software and outdated hardware are long gone.

I'm not aware of anything that can take your binary image and make it modern. In fact, I'm pretty sure it would be impossible to write such a thing.
 
Did the program in question ever have 'windows file management, resizeable graphics, etc'?

If it did, and you have the original source code, it could probably be recompiled with a modern compiler, although I'm sure there would be some level of effort to update the source itself to compile in the 21st century, but it might not be a huge task.

If the original source code didn't do that stuff then really you'll need a Windows developer to take that source code and then use it as the basis of a new Windows application. That's certainly doable, but there would be a significant level of effort involved.

I'm not aware of anything that can take your binary image and make it modern. In fact, I'm pretty sure it would be impossible to write such a thing.

No, it had push a number menu selection and static graphics. I understand that menus and graphics would have to be redone, but neither are that complex. What is complex is the mathematical core, which contains a linear equation solving routine and a matrix inverter (which, by the way, I rewrote in C from the original source code in Fortran.) If I can compile those modules clean, then it would make the project worth my effort.
 
Those should be relatively trivial to port, unless you have libraries to do the nasty stuff.

Largely, C is C, for numerics. Turbo C is really old C. You'll probably need to turn on a K&R flag to compile.

Where you will get in trouble is the out of bounds handling. If it's IEEE 768 compatible, it will be OK, but not everything was in the 80s.

That is, unless you tried to get fancy with binary layout (e.g., unions). Then, you will learn to curse your ancestors for having done "what comes naturally."

Interface work is a ton of effort, though. That's clearly going to need to be redone.
 
I waited, because this isn't what the original poster asked, really, but...

If you're going to go to all the trouble to port it, you might consider a few design changes to make it less painful the next time it gets ported (and, since it's this old and still used, that's entirely possible).

* clean separation between gui and core. Document the hell out of the core.
* consider something other than windows gui. There are multi platform gui toolkits... Qt, WxWidgets, etc.
* You might even port to javascript, depending.
* Consider making it a mobile app. This would be easier if the language the core libs were written in was portable to a handset.
* The graphics capabilities are amazing compared to what was originally in Turbo C. After the port, plan for some upgraded display geewhizzyness.

Sounds like a fun project. :)
 
Okay so I have an engineering program that runs under MS DOS with graphics and data entry screens all hard coded in Turbo C. Is there any way to convert it in to a Windows application without rewriting the entire thing? I realize that graphics, data entry and file handling will be new but it would sure put me out rewriting the computational routines.

No I am not a Windows developer nor do I presently have the tools. My programming experience ended at pre-Windows C, Fortran and Basic.

Short answer - no, there's no way to convert without rewriting that I'm aware of. You might find someone who geeked out on writing a converter explicitly for this, but at best I'd think you'd get it up to a very old version of Visual C circa 1998.

All the window handling routines and techniques are pretty much completely different. I think you're going to need to put the blinders on, learn a modern language and convert it.
 
I waited, because this isn't what the original poster asked, really, but...

If you're going to go to all the trouble to port it, you might consider a few design changes to make it less painful the next time it gets ported (and, since it's this old and still used, that's entirely possible).

* clean separation between gui and core. Document the hell out of the core.
* consider something other than windows gui. There are multi platform gui toolkits... Qt, WxWidgets, etc.
* You might even port to javascript, depending.
* Consider making it a mobile app. This would be easier if the language the core libs were written in was portable to a handset.
* The graphics capabilities are amazing compared to what was originally in Turbo C. After the port, plan for some upgraded display geewhizzyness.

Sounds like a fun project. :)

Good points.

Short answer - no, there's no way to convert without rewriting that I'm aware of. You might find someone who geeked out on writing a converter explicitly for this, but at best I'd think you'd get it up to a very old version of Visual C circa 1998.

All the window handling routines and techniques are pretty much completely different. I think you're going to need to put the blinders on, learn a modern language and convert it.

I was afraid of that. It wouldn't be an impossible task though.
 
2Balla: If this code has a potential to be used commercially, I might be able to help you port it.
 
Back
Top