x86 保护模式下段寄存器的用途是什么? [英] What is the purpose of segment registers in x86 protected mode?

查看:25
本文介绍了x86 保护模式下段寄存器的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要修改一些 dll,但我不知道,在保护模式下段寄存器(DSSS、...)究竟做了什么.我在学校学到了真正的 16 位模式,其中段寄存器乘以 16 加上正常寄存器中的偏移量给出物理内存中的有效地址.在保护模式下,有一些平面内存模型和虚拟内存,其中每个进程有"4GB 内存,所以如果寄存器有 32 位,那么我只能通过偏移"寄存器来寻址虚拟内存的每个字节.那么哪些目的在保护模式下有段寄存器,例如

I need to modify some dll, but i don't know, what excatly does segment registers (DS, SS, ...) in protected mode. I learned in school about real 16-bit mode, where segment registers multiply by 16 plus offset in normal register gives effective address in physical memory. In protected mode, there is some flat memory model and virtual memory, where each process "has" 4GB memory, so if registers have 32-bit, then i can address each byte of virtual memory only by "offset" register. So which puproses have segment registers in protected mode, for example

mov eax, dword ptr ds:[20037DA0] 

推荐答案

除了工作方式略有不同外,目的与实模式基本相同.您的示例中的 DS 在您的 GDT 中选择一个内存描述符(如果您真的想了解这一点,请谷歌这个术语,全局描述符表"),其中包含基地址、结束地址、粒度等信息.然后将您的偏移量添加到基地址, 结束.如果你在 windows 上(我打赌在 linux 上是一样的)你通常不必担心这些段寄存器,正如你所说的它的平面模型,这意味着所有内存应该只有一个描述符,所以如果你不改变这些寄存器应该像它们不存在一样工作.

Basicaly the purpose is the same as in real mode except the way they work is slightly different. DS in your example selects one memory descriptor in your GDT(google this term if you really wanna understand this, "Global descriptor table") which contains information like base address, end address, granularity etc. Your offset is then added to the base address, the end. If you are on windows (i bet on linux its the same) you dont generaly have to worry about these segment registers, as you said its flat model, that means there should be only one descriptor for all the memory, so if you dont change these registers it should work as if they werent even existing.

这篇关于x86 保护模式下段寄存器的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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