Using doscmd
Marc Fonvieille <[email protected]>
Introduction
FreeBSD's userland comes with many useful programs,
but most users don't even know they exist.
doscmd(1) is one of these applications.
doscmd(1) allows you to run DOS programs, and
it can even emulate a DOS machine (i.e., boot DOS).
It supports text-applications only.
Getting Ready
First, let's find the doscmd(1) binary:
% whereis doscmd
doscmd: /usr/bin/doscmd /usr/share/man/man1/doscmd.1.gz
If whereis gives you an empty result, su
to root, install the source tree, and do the
following:
# cd /usr/src/usr.bin/doscmd && make clean all install
If this message appears:
make: don't know how to make /usr/obj/usr/src/i386/usr/include/stdio.h. Stop.
It means your /usr/obj directory is empty,
and you have to make
world to populate it.
To run doscmd(1), you don't need a high-end
system. Something along the lines of a P200 with 32MB
of RAM running X should be plenty. FreeBSD 3.X users
will need to build a kernel with the following options
in order to run doscmd(1):
options "VM86"
To run correctly, doscmd(1) needs a vga
font. If you have a recent 4.X source tree (after
June 30, 2000), the font is included with the source
and you just have to run the following before running
doscmd(1):
% xset fp+ /usr/libdata/doscmd/fonts
This command could also be added to your
.xinitrc file.
If you don't have a source tree from after June 30,
2000, you'll have to do the following:
Fetch this
file.
Run the following commands as root:
# uudecode cp437-8x16.pcf.gz.uu > cp437-8x16.pcf.gz
# cp cp437-8x16.pcf.gz /usr/X11R6/lib/X11/fonts/misc/
# mkfontdir /usr/X11R6/lib/X11/fonts/misc/
# xset fp rehash
In this case, I didn't create
/usr/libdata/doscmd/fonts, I chose to use
an existing fonts directory instead.
Configuration
In the following section I'm going to explain how to
boot from a floppy disk image and run DOS
applications.
First, we need a DOS boot floppy:
find a box running DOS
format a: /s
copy /usr/libdata/doscmd/redir.com onto the
floppy
add a config.sys file on the floppy
with the following lines:
buffers=20
files=35
lastdrive=Z
Add an autoexec.bat file on the
floppy with the following lines:
@echo off
redir.com
PATH a:\;
If you create these files from a FreeBSD machine,
you will have to convert them to DOS format (add a
carriage return at the end of each line):
perl -p -e 's/$/\r/' < unixfile > dosfile
Create a boot floppy:
dd if=/dev/rfd0 of=/home/user/boot.dos
About the DOS version -- I tried MS-DOS 6.22 and it
worked without any problems. FreeDOS, on the other
hand, hangs.
The next step is to configure ~/.doscmdrc.
Put the following lines in it:
boot A:
assign A: /home/user/boot.dos 1440
assign C: /home/user/dos
The first line is needed to boot on the A:
device, the 1440 tells doscmd(1) that the
floppy image is a 1.44MB image, and the third line
points to a directory that will be seen as
C:\. This is the directory where I'd put
my DOS programs.
I currently have only managed to run
doscmd(1) under X. Even a build with -DNO_X
defined won't run on the console.
Now we're ready to launch doscmd(1). From
an xterm, do the following:
% doscmd -b -x
You should see a window like this one appear.
If execution failed with this message:
doscmd: fatal error X11 support not compiled in
do the following as root:
# cd /usr/src/usr.bin/doscmd && make clean all install
Another thing to note is that each time I ran
doscmd(1), I got these messages (however,
they can be ignored):
Unknown interrupt 15 function 4101
Unknown interrupt 15 function 87d9
In order to run an application, it's done the same as
it is on a real DOS machine -- you simply have to type
the name of the executable.
Use and Conclusion
doscmd(1) runs in a small window (640x400
only), but it's sufficient for any text application.
I used it to run Turbo C 2.0 from Borland, which you
can see here,
and PALASM from AMD. PALASM is a program which
translates boolean functions and state transition
tables into a fuse map for use with a Programmable
Array Logic (PAL) device. You can see it in action here, here, and here. I tried to
use serial port resident programs without success.
doscmd(1) is quite slow, however it can do
the job with old DOS applications quite well.
- Marc Fonvieille
Return to the
March 2001 Issue