Nostalgic DOS Development – Setting up the machine

The modern world is far too complex. Software has become piles of APIs stacked on top of each other, running on virtual machines inside browsers. Even the CPUs themselves are too complex for anyone to understand.

Let’s ditch all that complicated nonsense and go back to a time when computers were complex enough to be useful, but simple enough individuals could still beat on the bare metal without getting lost.

I figure that if people can get nostalgic over restoring old PCs and playing games on them, we can do the same for programming on them.

Here’s a step by step guide on how to set up a DOS environment for programming. I’m assuming you’re smart enough to read and follow instructions, so some of the gaps will need filling in with your own imagination and research.

Getting a DOS Environment

I’m going to be using 86box, it is an emulation of a PC – literally everything from the motherboard, CPU and video card, and which IDE controller you have to what type of floppy drive is installed.

86Box has its own instructions they’re easy to follow. Make sure you also install a manager so you don’t have to hand edit the 86box config file. We’re setting up a DOS PC here, getting that running is enough excitement without trying to hand craft a config file.

Once it’s installed, you need to set up a fairly basic 486DX2/66 system with something like 16MB of RAM and a 500MB hard disk, a floppy drive and a mouse. Make sure it has a VLB or PCI graphics card. All of this is fairly period accurate, so if you don’t want to do this in an emulator you can always use a real computer.

Installing DOS in 86Box

It’s best to use FreeDOS, it’s available as an install image, you will probably want the version for legacy systems that comes with a bootable floppy disk image as well as a CDROM.

Don’t bother installing all the extras for FreeDOS, we just need the OS to boot up. Edit your fdauto.bat and fdconfig.sys files to remove all the junk FreeDOS puts in them. You need a basic DOS environment with an XMS memory manager and a load of free conventional RAM.

Here is my fdauto.bat (FreeDOS doesn’t call it autoexec.bat don’t mix them up!)

@ECHO OFF
REM Standard AutoExec Batch File
set DJGPP=C:\DJGPP\DJGPP.ENV
set DOSDRV=C:
set DOSDIR=C:\FreeDOS
set LANG=EN
set TZ=UTC
set PATH=%dosdir%\BIN;C:\DJGPP\BIN;c:\masm\bin;c:\tc
if exist %dosdir%\LINKS\NUL set PATH=%path%;%dosdir%\LINKS
set NLSPATH=%dosdir%\NLS
set HELPPATH=%dosdir%\HELP
set TEMP=%dosdir%\TEMP
set TMP=%TEMP%
set BLASTER=A220 I5 D1 H5 P330
set DIRCMD=/P /OGN /Y
set COPYCMD=/-Y
set OS_NAME=FreeDOS
set OS_VERSION=1.3

mkeyb UK
call %dosdir%\bin\cdrom.bat
MEM /C /N
Code language: DOS .bat (dos)

If you live in the UK, make sure the UK keyboard mapping is enabled!

mkeyb UKCode language: DOS .bat (dos)

Here is my fdconfig.sys

SET DOSDIR=C:\FreeDOS

!COUNTRY=044,858,C:\FreeDOS\BIN\COUNTRY.SYS
!LASTDRIVE=Z
!BUFFERS=20
!FILES=40

DOS=HIGH,UMB
DEVICE=C:\FreeDOS\BIN\JEMMEX.EXE NOEMS X=TEST NOVME NOINVLPG
SHELLHIGH=C:\FreeDOS\BIN\COMMAND.COM C:\FreeDOS\BIN /E:1024 /P=C:\FDAUTO.BAT

At this point you should have a functional DOS PC emulation running in 86Box.

Installing Development Tools in DOS

We’re programming in C, and we’re trying to do it without just replicating Linux in DOS. So no vi or Emacs, but we are going to use GCC through the DJGPP compiler tool chain. This is period correct, so it counts. So there.

For an editor I settled on using something called RHIDE. It has the same look as DOS Edit and the Turbo Pascal and Turbo C++ editors from Borland. I like this style of editor, I wish it still existed.

Installing DJGPP & RHIDE

DJGPP can be downloaded from its website, which still exists. They have a very handy zip picker that guides you through choosing the correct files. DJGPP is one of those websites that time forgot, and is still maintained.

Make sure you tell the zip picker you want to also install RHIDE as your editor so it tells you which zip file to download.

Getting the files into DOS

The zip picker will instruct you to download a set of zipfiles along with an unzip utility. Gather these all together into a folder on your host machine.

The zip picker page also gives you instructions on how to install DJGPP and RHIDE but it doesn’t explain how to get those files into your DOS machine in the first place.

This is a fundamental limitation with DOS and 86Box. 86Box is a pretty accurate emulation of an entire PC, it isn’t just an emulation layer simulating DOS. So there is no way to access your local machine from inside DOS. The only ways we can get data in and out of the DOS environment is via CDROM images and floppy disk images.

To get files into our DOS system make use of the virtual CDROM feature in 86Box. First make sure you have a CDROM driver loaded. FreeDOS does this by default and it will tell you when you boot DOS.

Note that the virtual CDROM is literally read only, you can’t copy files into it from DOS. And you can’t update the files inside it from the host without “ejecting” and reinserting the virtual CD.

Once you have the files visible in DOS, just follow the installation instructions.

Getting files out of DOS

To get files out of DOS is a bit more annoying. About the only way I can easily figure out is to make floppy disk images and then mount them in your host OS.

First create a new floppy image from within FreeDOS

Make sure you choose 1.44MB as the size, and put .img at the end for the extension.

Then, because it’s DOS, format the disk from within DOS

Now use regular DOS commands to copy files onto it.

If you then eject the disk image, you can use some sort of floppy mounting tool in your OS to get at the files. In Linux it just seems to sort of know what to do, possibly something similar on a Mac. In Windows you will need a tool like WinImage.

4 responses to “Nostalgic DOS Development – Setting up the machine”

  1. JPC avatar
    JPC

    Following to Hello World,
    Next software could be counting from 1 to 1 Billion,
    to test the speed of the machine..
    https://www.youtube.com/watch?v=VioxsWYzoJk

    there are many other similar fun programs…
    the machine on the video is unknown,
    but a z790 + 12100 is much faster.

  2. JPC avatar
    JPC

    philscomputerlab.com has a compilation of tools for test & benchmarks, very common to test DOS machines.

  3. JPC avatar
    JPC

    DosBox-X allows to slow the speed of the CPU near 0
    https://www.youtube.com/watch?v=_FxHyofXglI&t=101s
    could be useful for debug.

Leave a Reply

Your email address will not be published. Required fields are marked *