executabledos

How does DOS load a program into memory?


What steps does MS-DOS take to load a COM or EXE file into memory? Are there still references online as to how this happens? The best I can think of is possibly referring to dosbox source.


Solution

  • When command.com is asked to execute a .com or .exe file, it will call the interrupt service 21h/AH=4B, the EXEC service. It is up to the calling program to:

    When interrupt 21h is called (here's where it gets hazy for me):

    for exe:

    for com:

    Program should now be executing.


    Notes:

    In Microsoft's KB document "Order of Precedence in Locating Executable Files", it mentions the use of "MS-DOS EXEC function (interrupt 21h service 4Bh)" for executing .com and .exe files http://support.microsoft.com/kb/35284

    So we can look at Ralph Brown's Interrupt List on Int 21/AH=4Bh

    and an example of use:

    and the dos exe header format:

    (this is based off some googling, so please feel free to add suggestions)