Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Ralf Brown's Interrupt List (Part 1,2) - int 21 - dos 2+ - load or execute (exec) http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
INT 21 - DOS 2+ - LOAD OR EXECUTE (EXEC)
        AH = 4Bh
        AL = subfunction
            00h load and execute program
            01h load but do not execute (internal)
            03h load overlay; do not create PSP
            04h called by MSC spawn(P_NOWAIT,...) when running DOS 4.x.
                returns unsuccessfully under DOS 4.0 (but may be successful
                  in the original European OEM MSDOS 4.0, which has limited
                  multitasking built in)
        DS:DX -> ASCIZ filename
        ES:BX -> parameter block (see below)
Return: CF set on error
            AX = error code (01h,02h,05h,08h,0Ah,0Bh) (see AH=59h)
        CF clear if successful
            if subfunction 01h, process ID set to new program's PSP; get with
                INT 21/AH=62h
Notes:  DOS 2.x destroys all registers, including SS:SP
        for functions 00h and 01h, the calling process must ensure that there
          is enough unallocated memory available; if necessary, by releasing
          memory with AH=49h or AH=4Ah
BUG:    DOS 2.00 assumes that DS points at the current program's PSP
SeeAlso: AH=4Ch,AH=4Dh,INT 2E

Format of EXEC parameter block for AL=00h,01h:
Offset  Size    Description
 00h    WORD    segment of environment (0 = use current) (see AH=26h)
 02h    DWORD   pointer to command line
 06h    DWORD   pointer to first FCB (see AH=0Fh)
 0Ah    DWORD   pointer to second FCB (see AH=0Fh)
 0Eh    DWORD   (AL=01h) will hold subprogram's initial SS:SP on return
 12h    DWORD   (AL=01h) will hold entry point (CS:IP) on return

Format of EXEC parameter block for AL=03h:
Offset  Size    Description
 00h    WORD    segment load address
 02h    WORD    segment relocation factor

Format of .EXE file header:
Offset  Size  Description
 00h    WORD  4Dh, 5Ah signature (sometimes 5Ah, 4Dh)
 02h    WORD  image size remainder (program size mod 512, not including header)
 04h    WORD  number of 512-byte pages needed to hold .EXE file (incl header)
 06h    WORD  number of relocation items
 08h    WORD  header size in paragraphs
 0Ah    WORD  minimum extra paragraphs needed
 0Ch    WORD  maximum extra paragraphs needed
 0Eh    WORD  stack segment
 10h    WORD  stack offset
 12h    WORD  word checksum of entire file
 14h    DWORD initial CS:IP
 18h    WORD  offset of relocation table
 1Ah    WORD  overlay number
Note:   if word at offset 02h is 4, it should be treated as 00h, since pre-1.10
          versions of the MS linker set it that way

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson