<<< Scaling Factors | Index | Addressing Instruction Operands Summary >>> |
In indirect memory addressing the base register identifies which segment register will be used to calculate the actual memory location.
Therefore, we need to understand the rules that define which register is the base register in indirect memory addressing mode.
The default segment register is SS if the base register is EBP or ESP.
However, if EBP is scaled, the processor treats it as an index register with a value relative to DS, not SS.
All other base registers are relative to DS.
If two registers are used, only one can have a scaling factor.
The register with the scaling factor is defined as the index register.
The other register is defined as the base register.
If scaling is not used, the first register is the base.
If only one register is used, it is considered the base for deciding the default segment, unless it is scaled.
The following examples illustrate how to determine the base register:
mov eax, [edx][ebp*4] ; EDX base (not scaled - seg DS) mov eax, [edx*1][ebp] ; EBP base (not scaled - seg SS) mov eax, [edx][ebp] ; EDX base (first - seg DS) mov eax, [ebp][edx] ; EBP base (first - seg SS) mov eax, [ebp] ; EBP base (only - seg SS) mov eax, [ebp*2] ; EBP*2 index (seg DS)
<<< Scaling Factors | Index | Addressing Instruction Operands Summary >>> |