Function 4B00h Load and Execute Program

mov dx, seg ProgName

mov ds, dx

mov dx, offset ProgName ;ds:dx points to program name

mov bx, seg ProgArgs

mov es, bx

mov bx, offset ProgArgs ;es:bx points to LOADEXEC structure

mov ax, 4B00h ;Load and Execute Program

int 21h

jc error_handler ;carry set means error

Load and Execute Program (Function 4B00h) loads a program into memory, creates a new program segment prefix (PSP), and transfers control to the new program.

Parameters

ProgName

Points to a zero-terminated ASCII string that specifies the program to load. The program name must be a valid MS-DOS filename, and the file must be a valid .COM or .EXE program.

ProgArgs

Points to a LOADEXEC structure that contains information the child program uses. The LOADEXEC structure has the following form:

LOADEXEC STRUC

leEnvironment dw ? ;environment-block segment

leCommandTail dd ? ;address of command tail

leFCB_1 dd ? ;address of default FCB #1

leFCB_2 dd ? ;address of default FCB #2

LOADEXEC ENDS

For a full description of the LOADEXEC structure, see Chapter 5, “Program Management.”

Return Value

If the function is successful, the carry flag is clear. Otherwise, the carry flag is set and the AX register contains an error value, which may be one of the following:

Value Name

0001h ERROR_INVALID_FUNCTION
0002h ERROR_FILE_NOT_FOUND
0003h ERROR_PATH_NOT_FOUND
0004h ERROR_TOO_MANY_OPEN_FILES
0005h ERROR_ACCESS_DENIED
0008h ERROR_NOT_ENOUGH_MEMORY
000Ah ERROR_BAD_ENVIRONMENT
000Bh ERROR_BAD_FORMAT

Comment

There must be enough free memory for MS-DOS to load the program file. All open files of the parent program, except files that were opened in no-inheritance mode, are available to the newly loaded program.

See Also

Function 31h Keep Program
Function 4B01h Load Program
Function 4B03h Load Overlay
Function 4B05h Set Execution State
Function 4Ch End Program
Function 4Dh Get Child-Program Return Value