
			The DOS emulator

(note: not to be comfused with dosemu, which is a IBM emulator that runs
MSDOS. )

This is a very small subset of what is needed to fully emulate MSDOS without
using any of MSDOS itself.  I re-wrote this from version 0.2x of dosemu over
a period of about a week, and then left it to rust for about six months.  I
would very much like to see something come from this idea, as it is a (IMHO)
much nicer method of running DOS programs than dosemu.  As I dont have full
internet connectivity and because I am not particuarly good at C programming
I wont offer to co-ordinate development of this code.  I would hovever like
to be involved in whatever happens with this - so, anyone who reads this and
goes on to use/modify the code, I would apreciate it if you dropped me a
line and told me about it.

About the code:
---------------

Only .COM files are currently loadable..
The one program that executes (almost) so far is PKUNZJR.COM - and that
program could be made to work quite easialy as is fails on things like
changing attribs... (in fact, you may find that I have altered this code to
make it work :)
File functions are done by passing _DIRECTLY_ the file-handle from Linux
to the DOS program - I _think_ that this is safe, but, still seems a likely
point for problems to me.
There is a define for the debugging file in global.h (yes, I could make it
a command-line option, but that would mean that I would have to learn how to
use getopt, or somesuch, and the current command-line usage is nice, simple
and efficient.

This seems like a good time to put my philosiphy (spell?) fowrard..

I dont like raw keyboard access, or raw video access - because that
precludes terminals/telnet's etc.. from using the code.  I dont like
clearing the screen or other such sillyness because that means that you cant
use a script and make the dos program look like a _real_ unix program.  I
dont like emulating devices, because I have yet to find a DOS program that
would use those devices that works better than the unix program, so I just
dont use programs that need those devices.  I dont like it, but I have to
accept that I need to emulate some things that an annoyingly large number of
programs expect - ie: the video status reg (inp's are currently set to give
some emulation for reading from the video status ... note: only _some_). I
also dont like needing special priviledges (suid Root, etc).

My ultimate idea was to end up with a program that I could use as a shell
for DOS programs - like you use /bin/sh as a shell for shell-scripts.  It
would be trivial to change the exec function to exec the dosemulator instead
of the program, if it finds the magic-number for a .EXE file (.COM files are
a little trickyer, but the general case magic-number's could be used and
shell-wrappers for others).

[One day later ;-)]
Right,. I got side-tracked into getting this working - It wouldnt work
because between now and the last time I used it, some things changed to make
executable areas to be non-writeable: making the emulator fail with
sigsegv's while initilizing the low-mem area..., and now - PKUNZJR.COM
_seems_ to work, but has _strange_ problems now-and-again (!) - I put some
really not nice date-and-time functions (basically, it does nothing, but
doesnt halt the emulator) and it worked..

Running the program:
--------------------

All that you should need to do to get this working is a make in its
directory.  The one option is the logging option (mentioned above).  To
install you need to be root, then just 'make install' - it uses the library
'dosemu.2d'. To use it run like this:

		dos <dos-.COM-file> <paramaters.....>

and all should be fine.  NOTE: you do NOT need to make the 'dos' stub file
suid or sgid to root, and you dont even need any special priviledges to run
this emulator.  Included are two dos programs - cmdline.com, which just
prints out its command-line, and list.com, which I was using as my 'program
to get running' until I ran into the brick-wall of allocation routines. 
When you run a program, your debugging output will include the number and
description of any DOS calls and Video and Disk BIOS calls.  Also, if the
program running hits some un-implemented things, or it does something that I
thought might need detailed warning about, the emulator will dump the
registers and disassemble the instruction pointed to by CS:IP.  The
dissasembly routines were stolen from the Mach IBM-emulator, and they noted
that they had stolen it from GNU GDB.  It is different from the current gdb
80x86 dis-assembly code, but I like it better than the latest code (it is
more self-contained and only needs the one file), but this could be because
it was modified by the Mach people, i dont know...


Anyway, that is enough waffle...
If you have any questions, dont hesitate to drop me a line.

		Hamish Coleman  (hamish@zot.apana.org.au)
