[comp.sys.ibm.pc] code for com/exe loader

dee@linus.UUCP (David E. Emery) (02/24/88)

I thought it would be nice to write a new command processor that
replaces COMMAND.COM.  However, COMMAND.COM contains the MS-DOS loader
code.  Does anyone know of any PD code that can be used to load .COM
and .EXE files into memory?  If i replace the DOS command processor,
what other things will I have to worry about (besides setting up the
PSP)? 
			dave emery
			emery@Mitre-bedford.arpa
			emery@bix

madd@bu-cs.BU.EDU (Jim Frost) (02/24/88)

In article <25118@linus.UUCP> dee@linus.UUCP (David E. Emery) writes:
>I thought it would be nice to write a new command processor that
>replaces COMMAND.COM.  However, COMMAND.COM contains the MS-DOS loader
>code.  Does anyone know of any PD code that can be used to load .COM
>and .EXE files into memory?  If i replace the DOS command processor,
>what other things will I have to worry about (besides setting up the
>PSP)? 

Last summer I spent a considerable amount of time creating a prorgram
called "psh" that was a csh look-alike for MS-DOS, written in Turbo
Pascal 3.0.  The resultant program worked on many systems, although
not on all of them that I tried.

Apparently some MS-DOS versions take care of .EXE relocation tables
inside the EXEC command without the need of COMMAND.COM, and some do
not.  Since my version did, I never built the necessary routines to
handle relocation.

Some things that you have to do with any version are:

	*build FCB's from the given command line and pass pointers to
	 them with the EXEC call.  If you fail to do this, many MS-DOS
	 utilities will not work under your shell.
	*remember to prepend the argument string with a space.  Some
	 MS-DOS utility programs (and some other programs I tested)
	 refused to work without this.

Obviously you have to handle path search and the environment.

For anyone who would like some example code, I will send
source/executable copies of psh to them if I'm sent a good return
address.  Note that psh is not complete enough to use as a replacement
shell -- there are several bugs in it that I haven't bothered to track
down since I don't use PC's too often anymore.  The code may be
helpful to those trying to make a shell, however, and this is why I'm
offering it.

Psh also has quite a few routines in it that imitate C functions in
Pascal (since the environment is in C-style I just made everything
C-style), which might be of use to someone.  Psh was written before
the release of TPascal 4.0; no effort has been expended to port it to
4.0, although 4.0 contains some additions that would have made
implementation of some of its functions a lot easier.

The psh source code, executable, and PC-Write document file can be
sent to you in a uuencoded ARC file.  If you can't handle that format,
say so and I'll see what I can do.

jim frost
madd@bu-it.bu.edu