Function 4B01h Load Program

mov dx, seg ProgName

mov ds, dx

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

mov bx, seg LoadArgs

mov es, bx

mov bx, offset LoadArgs ;es:bx points to LOAD structure

mov ax, 4B01h ;Load Program

int 21h

jc error_handler ;carry set means error

Load Program (Function 4B01h) loads a program into memory and creates a new program segment prefix (PSP) but does not transfer 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.

LoadArgs

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

LOAD STRUC

ldEnvironment dw ? ;environment-block segment

ldCommandTail dd ? ;address of command tail

ldFCB_1 dd ? ;address of default FCB #1

ldFCB_2 dd ? ;address of default FCB #2

ldSSSP dd ? ;starting stack address

ldCSIP dd ? ;starting code address

LOAD ENDS

For a full description of the LOAD 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.

See Also

Function 4B00h Load and Execute Program
Function 4B03h Load Overlay
Function 4B05h Set Execution State