什么决定了内存模型? [英] what determines the memory model?

查看:105
本文介绍了什么决定了内存模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具体来说,此问题与实模式下的平面模型和分段模型有关.我正在阅读一本有关汇编的书,其中提到在DOS上COM文件使用平面内存模型,而EXE文件使用分段内存模型.但是我不明白是什么告诉DOS使用哪种内存模型.我问这个问题是因为我正在阅读有关引导加载程序的信息.

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.

推荐答案

COM文件使用平面内存模型",即当程序加载时,段寄存器由DOS设置为alll,以指向同一段,按照惯例,所有代码和指针都相对于段寄存器中的那个值.

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.

另一方面,EXE文件格式允许以不同的偏移量加载段. DOS不会将段寄存器设置为默认值.这取决于代码本身. 16位EXE代码要复杂得多,因为该代码必须管理段寄存器.

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.

如今,许多EXE代码或多或少再次忽略了段寄存器.无需将32位或64位寄存器添加到段寄存器中即可生成可用地址.

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.

这篇关于什么决定了内存模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆