什么是有效地址?

What is an effective address?

在读取 Intel 64 and IA-32 Architectures Software Developer’s Manual 时,LEA 指令的操作部分(加载有效地址)使用称为 EffectiveAddress(SRC) 的计算,该计算未在其他任何地方定义。

有效地址的定义是什么,EffectiveAddress(SRC)有什么作用?

同一文档的第 3.7.5 节(指定偏移量)指出:

The offset part of a memory address can be specified directly as a static value (called a displacement) or through an address computation made up of one or more of the following components:

  • Displacement — An 8-, 16-, or 32-bit value.
  • Base — The value in a general-purpose register.
  • Index — The value in a general-purpose register.
  • Scale factor — A value of 2, 4, or 8 that is multiplied by the index value.

The offset which results from adding these components is called an effective address. Each of these components can have either a positive or negative (2s complement) value, with the exception of the scaling factor.

EffectiveAddress 使用以下方法计算有效地址

Base + (Index*Scale) + Displacement

有效地址是段基地址的偏移量。当您在保护模式(32 位模式)下看到类似 call 0x80000000 的内容时,CPU 将 0x80000000 添加到 CS 段寄存器指向的段的基地址。

在64位模式下,它等于线性地址,因为分段基本上被禁用了。