Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!bk0y+ From: bk0y+@andrew.cmu.edu (Brian Christopher Kircher) Newsgroups: comp.sys.ibm.pc Subject: Re: Dos Func. 4B emulation Message-ID: <8ZiwoM600WB8QxSWwE@andrew.cmu.edu> Date: 23 Jan 90 03:18:48 GMT References: <844@ocsmd.ocs.com>, <8283@cg-atla.UUCP> Organization: Class of '92, Carnegie Mellon, Pittsburgh, PA Lines: 48 In article <8283@cg-atla.UUCP> fredex@cg-atla.UUCP (Fred Smith) writes: >In article <844@ocsmd.ocs.com> motti@ocsmd.ocs.com (Motti Bazar) writes: >>I'm developing a DOS shell that plays with Interrupt 21H. >>One function (4B - Exec) is a tough one to emulate. Is there >>anybody that knows about any public domain code to emulete this >>function ??? If there is interest, I'll post the answer. >>Thanks in advance ... Motti. > >I don't understand--Int 21 function 0x4B is a function of DOS, not >the shell ( command.com) `As long as you have DOS you don't need >to "emulate" function 4B. But Int 21 function 0x4B is part of command.com. Quoting IBM's DOS Technical Reference Manual under its description of the various parts of command.com: "A transient portion is loaded at the high end of memory. This is the command processor itself, containing ... a routine to load and execute external commands. This 'loader' is at the highest end of memory, and is invoked by the EXEC function call to load programs." This explains why calling EXEC to load another program from within a program causes DOS to reload command.com (in the case that the transient portion was wiped by the program's execution before the EXEC). As far as actually implementing 0x4B, I would try: (but have never done this before :-) 1) two calls to 0x48, one to allocate a block to copy the environment into and the other to allocate the remainder of free memory to load the program into. 2) copy the current environment into the block allocated for the environment. 3) a call to 0x26 to create a PSP in the program's memory block 4) change some of the values in the PSP (such as the environment segment at 0x2c of the PSP, etc.) 5) if the program is a .com, load it starting at offset 0x100 in the program's memory block 6) if the program is a .exe, interpret the EXE header (I have no clue as to how this should be done) and load the program 7) set up the program's stack and jump to the first instruction of the program. I can't think of much else that would need to be done, but I'm not guaranteeing that this is complete or accurate. :-) Good Luck... Brian Kircher