DOS Fn 4b00H: Execute a Program

                                                         Compatibility: 2.0+ 
 Expects: AX    4b00H
          DS:DX address of an ASCIIZ filespec of the program to execute
          ES:BX address of an ExecParamRec
          ──────────────────────────────────────────────────────────────────
 Returns: AX    error code if CF is set to CY
          else  All registers are destroyed, including SS and SP
          ──────────────────────────────────────────────────────────────────
    Info: Provides a means for a program (the parent) to execute another
          program (the child).  When the child exits, control will return
          to the parent.  It prepares a PSP for the child, loads its code,
          performs any needed segment fixup, est the registers as expected,
          then begins executing the child program.

    DS:DX points to an ASCIIZ string in the form...
             d:\path\filename.ext◄0►
          If the drive or path is omitted, defaults are assumed.

    ES:BX points to a block of memory prepared as an ExecParamRec that has
          been filled with the information needed.

          Since the parent program initially receives all of available
          memory for its own processing, you must free some memory via
          Fn 4aH before performing using this fn.

          To EXEC a program:

          ■ Call Fn 4aH with ES=your PSP and the minimum amount of memory
            that your program requires (in paragraphs).
          ■ Prepare an ASCIIZ string of the program file to EXEC and set
            DS:DX to point to its first character.
          ■ Prepare an ExecParamRec containing all required fields
          ■ Save the current values of SS, SP, DS, ES, and the DTA in
            variables that are relative to CS (CS is the only point of
            reference after EXEC returns from the child).
          ■ Issue the EXEC call with AL=0
          ■ Restore SS and SP to local values
          ■ Check CF (the carry flag) to see if EXEC failed with an error
          ■ Restore DS, ES and the local DTA if necessary
          ■ Check the exit code▲ via Fn 4dH WAIT (if desired)

          All open files are duplicated, so the child can process data via
          file handle and/or use the standard I/O for input and output.
          Each handle's Access Mode is duplicated, but any "file locks"
          that are in effect will not belong to the child.  See Fn 5cH.

          Upon return from the child, the INT 22H (Terminate), INT 23H
          (Ctrl-Break), and INT 24H (Critical Error) vectors are restored
          to their previous values.

   Notes: ■ This function uses the loader portion of Command.Com which is
            transient in DOS 2.0+ (a program may have overwritten it).
            Thus, this call could fail if DOS can't locate the Command.Com
            file.  You should make sure that COMSPEC= in the environment is
            valid before the call.

          ■ Rather than parse the FCBs (as needed in the ExecParamRec), you
            may find it convenient to load and execute a secondary copy of
            Command.Com, using the /C option.  For instance, to execute the
            FORMAT.COM program, set DS:DX to the address of an ASCIIZ
            string:

              "c:\dos\command.com",0

            and set EPB+2 to the segment and offset of the command line:

              12H," /c format a: /s/4",0dH

            This secondary command interpreter uses a very small amount of
            memory (around 4K).  You can locate the drive and directory
            that contains COMMAND.COM by searching the DOS Environment for
            the COMSPEC string.

See Also: Fn 4b01H (load program)
          Fn 4b03H (load overlay)
          Process Control Functions
          Program Startup & Exit
          DOS Functions
                                    -♦-