[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function 4Bh (75)        Load or Execute a Program (EXEC)

    Loads a subprogram into memory and (optionally) executes it.

       On entry:      AH         4Bh
                      AL         00h          to load and run
                                 03h          to load but not run
                      DS:DX      Pointer to an ASCIIZ string specifying
                                 pathname of subprogram
                      ES:BX      Pointer to a parameter block

       Returns:       AX         Error code   If CF is set

       Error codes:   1          Invalid function number
                      2          File not found
                      3          Path not found
                      5          Access denied
                      8          Insufficient memory
                      10         Invalid environment
                      11         Invalid format

  --------------------------------------------------------------------------

    Function 4Bh (EXEC) allows a program to load a subprogram into memory
    and, optionally, execute it.

    If AL is 00h, the subprogram is loaded, a PSP is created, and the
    program is executed. The terminate and Ctrl-Break vectors are set to
    the instruction following the EXEC call, so that control returns to
    the calling program as soon as the subprogram ends.

    If AL is 03h, the subprogram is loaded, no PSP is created, and the
    subprogram is not automatically executed, although your program can
    jump to it.

    Load the DS:DX register pair with a pointer to an ASCIIZ string
    containing the drive, path, and filename of the file to be brought
    into memory. And load the ES:BX pair with a pointer to a parameter
    block to be passed to the incoming subprogram. The parameter block
    layout is as follows:

  For subfunction 00h (load and run)

       Offset    Size (bytes)   Description
        00h           2         Segment address of environment strings
        02h           4         Segment and offset of command line
        06h           4         Segment and offset of first default FCB
        0Ah           4         Segment and offset of second default FCB

  For subfunction 03h (load but don't run)

       Offset    Size (bytes)   Description
        00h           2         Segment address where file is to be loaded
        02h           2         Relocation factor for program (applies only
                                to EXE-format programs)
  --------------------------------------------------------------------------

       Environment:   The environment strings, which must be paragraph-
                      aligned, consists of a sequence of ASCIIZ strings
                      followed by a byte of 00h after all the strings.
                      Each ASCIIZ string typically takes the form of
                      parameter=value. The total environment string must
                      be less than 32K in length. If the segment for the
                      environment strings is set to 00h, the subprogram
                      inherits the environment of the calling program.

                      Note that the subprogram always recieves a copy of
                      the environment string, so that any changes made to
                      the subprogram's environment won't be reflected in
                      calling program's environment.

       Files:         When a subprogram is loaded and executed, all open
                      file handles are available to the subprogram. That
                      means, among other things, that the calling program
                      can redirect standard input and output for the
                      subprogram. The only file handles that are not
                      available to the subprogram are those that were
                      opened with the inheritance bit set to 1 (see
                      Function 3Dh).

       Memory:        Before using Function 4Bh, you must release enough
                      memory to load the subprogram (using function 4Ah).

       Warning:       This function changes all registers, including the
                      stack registers. Therefore, before calling a
                      subprogram, save SS and SP in variables inside your
                      program code.

       Note:          The EXEC function call uses the loader in
                      COMMAND.COM to load programs.

See Also: 3Dh 4Ah 4Dh 59h FCB PSP
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson