翻译:EXECUTABLE FILES .COM AND .EXE (2)
1. The program is loaded into memory and relocated.
2. Segment registers DS and ES are set to point to the beginning of the PSP.
3. Register CS, SS, SP, and IP are deterined by values.
There are advantages and disadvantages to both types of files. The .EXE file is larger than the corresponding .COM file because it contiains a file header. In addition, loading and executing the .EXE file will take longer because it must undergo relocation as it is loaded. But we've to use the .EXE type if the program is larger than 64KB. Furthermore, rel- ocation allows DOS to be more flexible in where it places the image in memory.
可执行文件.COM和.EXE
一个.EXE文件除了含有一个文件头外,还可以包含许多逻辑段。我们可以在.EXE文件中定义一些数据段、代码段和堆栈段等。因为文件头提供了连接时所不能确定的段的基准位置,所以当DOS装入.EXE文件时就得借助文件头来找到需重新定位的信息。
在装入.EXE文件时执行以下步骤:
1.程序被装入内存并重新定位。
2.段寄存器DS和ES指向PSP起始处。
3.确定CS、SS、SP与IP寄存器的值。
二类可执行文件均有优缺点。由于.EXE文件包含了一个文件头,因此它比对应的.COM文件长。另外,因为装入.EXE文件时须重新定位,所以装入与执行.EXE文件所费的时间较长。但是,如果程序超过64KB,我们就必须采用.EXE文件类型了。此外,重新定位使DOS能更灵活地在内存中安排映象。