what determines the memory model?

荒凉一梦 提交于 2019-12-10 15:20:09

问题


Specifically this question is about flat and segmented model in real mode. I am reading a book on assembly which mentions that on DOS the COM files use flat memory model and EXE files use segmented memory model. However I am not understanding what tells DOS which memory model to use. I am asking this question because I am reading about bootloaders.


回答1:


COM files used a "flat memory model" in the sense that the segment registers were alll set by DOS when the program was loaded to point to the same segment, and all the code and pointers were, by convention, relative to that one value in the segment registers.

The EXE file format, on the other hand, allows for segments to be loaded at different offsets. DOS wouldn't set the segment registers to default values; that was up to the code itself. 16-bit EXE code is a lot more complex because the code has to manage segment registers.

Nowadays a lot of EXE code more or less ignores segment registers again; 32 or 64-bit registers don't need to be added to a segment register to generate a usable address.




回答2:


There's nothing in DOS that can stop COM file from using segmented memory model, since DOS had no memory management policy enforced on it's applications.

You can read wikipedia entry about COM files, it gives an insight into these old matters.




回答3:


The COM and EXE executables had their memory requirements in a file header: EXE header and COM (MS-DOS) header. If the program requires < 64KB, use the flat space, if > 64KB, use segmented memory.



来源:https://stackoverflow.com/questions/9778425/what-determines-the-memory-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!