问题描述
MS-DOS采取什么步骤将COM或EXE文件加载到内存中?网上仍然有关于这种情况的参考吗?我能想到的最好的方法可能是指dosbox源代码。
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.
推荐答案
当要求command.com执行.com或.exe文件,它将调用中断服务21h / AH = 4B,即EXEC服务。由调用程序决定:
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:
- 构建DOS EXEC参数块(请参阅),并在内存中调整
远指针 - 设置寄存器值
- AL,AH盘符状态
- DS,ES-> PSP段(请参阅)
- SS:SP->堆栈指针(已定义
- exe header is read for initial register values
- copy code section from exe into memory
- relocation table (see http://en.wikipedia.org/wiki/Relocation_table) is read andfar pointers are adjusted in memory
- setup register values
- AL,AH drive letter status
- DS,ES -> PSP segment (see http://en.wikipedia.org/wiki/Program_Segment_Prefix )
- SS:SP -> stack pointer (defined in exe header)
com:
- 将整个.com文件复制到内存中
- 设置寄存器值
- AL,AH驱动器盘符状态
- CS,DS,ES,SS-> PSP段
- SP =前64k段中可用的最后一个字的偏移量
- copy entire .com file into memory
- setup register values
- AL,AH drive letter status
- CS,DS,ES,SS -> PSP segment
- SP = offset of last word available in first 64k segment
程序现在应该正在执行。
Program should now be executing.
注意:
在Microsoft的KB文档中查找可执行文件的优先级,它提到
使用 MS-DOS EXEC函数(21h中断服务4Bh)来执行.com和.exe文件
In Microsoft's KB document "Order of Precedence in Locating Executable Files", it mentions theuse of "MS-DOS EXEC function (interrupt 21h service 4Bh)" for executing .com and .exe fileshttp://support.microsoft.com/kb/35284
所以我们可以在Int 21 / AH = 4Bh上查看拉尔夫·布朗的中断列表
So we can look at Ralph Brown's Interrupt List on Int 21/AH=4Bh
- Int 21 / AH = 4Bh
- Int 21 / AH = 4Bh
- http://www.cs.cmu.edu/~ralf/files.html
- Int 21/AH=4Bh http://www.delorie.com/djgpp/doc/rbinter/id/51/29.html
- Int 21/AH=4Bh http://www.ctyme.com/intr/rb-2939.htm
以及使用示例:
- 组装艺术/ 19.1.1.1加载并执行
- Art of Assembly / 19.1.1.1 Load and Execute http://webster.cs.ucr.edu/AoA/DOS/ch19/CH19-1.html#HEADING1-10
和dos exe标头格式:
and the dos exe header format:
- http://www.delorie.com/djgpp/doc/rbinter/it/94/15.html
- http://www.delorie.com/djgpp/doc/exe/
(这是基于谷歌搜索,所以请免费添加建议)
(this is based off some googling, so please feel free to add suggestions)
这篇关于DOS如何将程序加载到内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!