Computing: Computer Administration

Running 32-bit applications on DOS.

A DOS extender is a computer software program running under DOS that enables software to run in a protected mode environment even though the host operating system is only capable of operating in real mode. DOS extenders were initially developed in the 1980s following the introduction of the Intel 80286 processor (and later expanded upon with the Intel 80386), to cope with the memory limitations of DOS.

Several of these extenders allow to run 32-bit protected mode applications on 16-bit DOS operating systems. This was not really popular in the good old times, but today, these extenders become really interesting for those who, for nostalgic or other reasons, play around with DOS. In fact, the GNU compiler collection for DOS runs on the DJ's GNU Programming Platform (DJGPP)), that produces 32-bit code. The only actual Free Pascal compiler, that runs on DOS, uses the go32v2 DOS Extender, that also produces 32-bit protected mode programs. And finally, the Open Watcom C/C++ and Fortran 77 compilers allow to build 32-bit programs for the DOS/4GW extender and Phar Lap 386|DOS-Extender In my tutorials Installing and running DJGPP (C, C++) on FreeDOS, Installing Free Pascal on FreeDOS and Building Open Watcom C/C++ and Fortran 77 programs on FreeDOS, I describe how to proceed to create 32-bit C, C++, Fortran 77 and Free Pascal programs. But, how to run these programs on another DOS computer?

If you take one of the executables created with DJGPP or go32v2 and try to run them on a standard MS-DOS 6.22, for example, you'll get the error message Load error: No DPMI - Get csdpmi*b.zip. You get the same message, if you try to run a 32-bit assembly executable (cf. 32-bit assembly programming using NASM and GCC). Trying to run a 32-bit program created for DOS/4GW (Open Watcom compilers), you'll get the error message Stub exec failed: \dos4gw.exe no such file or directory.

The DOS Protected Mode Interface (DPMI) is a specification introduced in 1989 which allows a DOS program to run in protected mode, giving access to many features of the new PC processors of the time not available in real mode. CWSDPMI is a 32-bit DPMI host written by Charles W. Sandmann from 1996 to 2010. It can provide DPMI 0.90+ 32-bit services for programs compiled with the latest versions of DJGPP and similar compilers. It supports up to 4 GB, virtual memory, and hardware interrupt reflection from real mode to protected mode. Programs compiled with DJGPP v2 require a DPMI host, which is usually cwsdpmi.exe or CWSDPR0.EXE. In the case of cwsdpmi.exe, the default paging/virtual memory file is C:\CWSDPMI.SWP. It is capable of running on a 386 with less than 512 KB of RAM.

You can download CWSDPMI from delorie.com. The download is a ZIP archive; extract its content into some directory on your DOS system, e.g. C:\DOS\DPMI. Among these files, note the DPMI host, called cwsdpmi.exe. There are several possibilities to use the extender.

I tested all this with the DPMI host included in csdpmi5b.zip on MS-DOS 6.22. It worked well for programs build with C and NASM (DJGPP), as well as with Free Pascal go32v2 applications.

To run the 32-bit programs for DOS/4GW created by the Open Watcom C/C++ and Fortran 77 compilers, the DOS extender dos4gw.exe must be present. You find this file in the binw subdirectory of the Open Watcom C/C++ installation folder, and you can copy it (for example, using a floppy diskette) to your other DOS machine. Here place it in a directory that is in the executables path, e.g. C:\DOS on a MS-DOS 6.22 system. That is all you have to do. When you run the 32-bit program, the extender is automatically loaded and the program is executed in 32-bit protected mode.

What about 32-bit GNU-Fortran (g77) programs? If you installed g77 with EMX, as I describe in my tutorial Installing and running Gnu Fortran on FreeDOS, trying to execute the executables results in the error message emx not found. EMX (Eberhard Mattes eXtender) is a programming environment for DOS and OS/2. It allows to create and execute 32-bit mode applications, presenting a POSIX API and, on OS/2, access to the OS/2 APIs. To use the extender with the g77 executables, place the file emx.exe in some directory on your DOS system (I placed it together with the csdpmi files in C:\DOS\DPMI) and add this directory to your PATH environment variable. That's all you have to do: When you run your 32-bit g77 executable, it automatically detects and loads the extender.


If you find this text helpful, please, support me and this website by signing my guestbook.