默认情况下使用哪个段寄存器? [英] Which segment register is used by default?

查看:670
本文介绍了默认情况下使用哪个段寄存器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从《英特尔手册》研究计算机体系结构.我了解的是,我们给出的指令是由段选择器和偏移量组成的逻辑地址. 基本上是CS register<<4 + offset. Segment Selector映射到段选择器的TI位中指定的 GDT LDT . GDT由具有BASELIMITRPLSegment Descriptors组成,并且输出是基地址.此base address + offset提供了logical address.

I am studying computer architecture from the Intel Manual. The thing that I understand is that the instructions that we give are logical addresses which consist of a segment selector and an offset. It is basically CS register<<4 + offset. The Segment Selector maps to the GDT or LDT as given in the TI bit of the segment selector. GDT consists of Segment Descriptors which have BASE, LIMIT and RPL and the output is base address. This base address + offset provides the logical address.

哪些规则决定哪个段寄存器(SSDS等)适用于不同的内存操作?例如是什么决定mov eax, [edi]使用哪个段?

What are the rules that decide which segment register (SS, DS, etc.) applies to different memory operations? e.g. what determines which segment is used for mov eax, [edi]?

推荐答案

您可以使用段覆盖前缀来选择哪个段将应用于指令中的内存操作数.

You can use a segment override prefix to select which segment will apply to the memory operand in an instruction.

代码提取始终使用CS.

大多数情况下默认时间是DS(例如mov eax, [edi]).一些反汇编程序即使在默认情况下也可以使该段显式显示,因此您会看到很多DS:会使反汇编输出混乱.

The default most of the time is DS (e.g. for mov eax, [edi]). Some disassemblers make the segment explicit even when it's the default, so you see a lot of DS: cluttering up the disassembly output.

movs指令[DS:ESI]并写入[ES:EDI],从而可以轻松在段之间进行复制,而无需使用段覆盖前缀.其他一些字符串指令也使用ES.

The movs instruction reads from [DS:ESI] and writes to [ES:EDI], making it easy to copy between segments without segment override prefixes. Some other string instructions also use ES.

使用espebp作为基址寄存器的内存操作数默认为SS,因此对

Memory operands using esp or ebp as the base register default to SS, and so do the implicit accesses for stack instructions like push/pop/call/ret.

FSGS从来都不是默认值,因此可以在诸如32位和64位现代操作系统的平面内存模型系统中用于特殊目的(例如线程本地存储).

FS and GS are never the default, so they can be used for special purposes (like thread-local storage) in a flat memory model system like modern 32 and 64-bit OSes.

维基百科在这里解释了同样的事情.

这也正式记录在

This is also documented officially in Intel's ISA manuals. e.g. in Volume 2 (the instruction-set ref), Table 2-1. 16-Bit Addressing Forms with the ModR/M Byte has a footnote saying:

对于包含BP索引的有效地址,默认段寄存器为SS,对于其他有效地址,默认段寄存器为DS.

The default segment register is SS for the effective addresses containing a BP index, DS for other effective addresses.

(请注意,SP对于16位寻址模式不是有效的基址.)

(note that SP isn't a valid base address for 16-bit addressing modes.)

没有用于32位或64位寻址模式的等效脚注,因此详细信息必须在手册的另一卷中.

There's no equivalent footnote for 32 or 64-bit addressing modes, so the details must be in another volume of the manual.

另请参见标签Wiki的问题,以了解更多信息链接.

See also the x86 tag wiki for more links.

这篇关于默认情况下使用哪个段寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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