基址比例变址寻址(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指令表示一些乘法运算。

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