基址比例變址尋址(Base Index Scale Addressing)

參考內容來自:https://docs.oracle.com/cd/E19120-01/open.solaris/817-5477/ennby/index.html

該尋址方式的形式爲 offset(base, index, scale)

原文中這樣描述

Memory references have the following syntax:segment:offset(base, index, scale).
  • Segment is any of the x86 architecture segment
    registers. Segment is optional: if specified, it must be separated from offset by a colon (:). If segment is omitted, the value of %ds (the default segment register) is assumed.

    • segment是x86架構的任意一個段地址寄存器。segment參數是可選的(可以不指定):如果指定了段寄存器,必須和偏移量之間有一個冒號。如果segment參數被省略,默認的段地址寄存器ds 就會被用於計算最終的地址。
  • Offset is the displacement from segment of the desired memory value. Offset is optional.

    • offset是指從段起始地址到目標變量地址之間的偏移量。offset同樣也是可選
  • Base and index can be any of the general 32–bit number registers.

    • base 和 index 參數可以是任意的32位通用寄存器
  • Scale is a factor by which index is to be multipled before being added to base to specify the address of the operand. Scale can have the value of 1, 2, 4, or 8. If scale is not specified, the default value is 1.

    • Scale參數是表示index寄存器內容需要乘的值,可以是1,2,4,8.默認是1.

例如指令 movl base(%ebx, %esi, 4), %eax
表示 %eax = [ base + %ebx + %esi*4 ]
base + %ebx + %esi*4 指向的內存位置的值賦值給eax寄存器。

例如 leal 32(, %edx, 8), %eax
%eax = 32 + ( %edx * 8 ) = 8 * (4 + %edx)
通常可以用lea指令表示一些乘法運算。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章