32bit DOS Development with Open Watcom
04 Oct 2015The Watcom Compiler is an open source C & C++ compiler that has a very successful history when it was discovered that the DOOM developers were using it. That was a very long time ago, but that shouldn’t stop us having a go!
Installation
I’ve grabbed the dos bundle from the Open Watcom FTP site and installed it into DosBox. The only problem with this setup, it that I much prefer to use a text editor that’s outside of the DOS environment (like emacs/sublime, etc.) DosBox sometimes has a bit of difficulty picking up file system changes that have been mounted in.
Shift + Ctrl + F4 (documented as just Ctrl + F4) forces DosBox to refresh its mounts.
Very handy.
The Tools
There are a bucket of binaries that are bundled with the installation.
Utility | Description |
---|---|
wasm.exe | Assembler |
whelp.exe | Help Command Line |
wmake.exe | Make utility |
wcl386.exe | Compile and Link |
wpp386.exe | Optimizing compiler |
wcc386.exe | Optimizing compiler |
wd.exe | Debugger |
wlib.exe | Library manager |
wlink.exe | Linker |
dos32a.exe | DOS32A extender |
wdis.exe | Disassembler |
For convenience, we’ll use wcl386.exe
as this will perform the compilation and linking step in one for us.
Compiling and Linking
Prior to compilation and linking, things will go a lot smoother if you’ve prepared your environment variables correctly.
Open up your favorite editor and create a hello world application, called hello.cpp
.
Now build it with wcl386.exe
:
We can now run our application:
What is DOS/4GW?
To a lot of us, the DOS/4GW is a very familiar banner that we saw when we’d fire up one of our favorite games. But, what is it?
Wikipedia’s article defines its role pretty well:
DOS/4G is a 32-bit DOS extender developed by Rational Systems (now Tenberry Software). It allows DOS programs to eliminate the 640 KB conventional memory limit by addressing up to 64 MB of extended memory on Intel 80386 and above machines.
It’s the resident binary that gets packaged with your compiled application that facilitates access to the computers’ full array of resources. Without it, you’d be stuck with what DOS provides you by default.
Conclusion
Well, it’s always nice to go over this old stuff. In my next posts, I’ll cover inline assembly and mode 13/x to get a head start on writing DOS games in the 90’s!