在x86-64组合中,movzbl(%rdi, %rcx, 1), %ecx是什么意思?

时间:2021-07-11 19:26:10

I thiiink I understand that

我知道这一点。

movzbl (%rdi, %rcx, 1) , %ecx

means "move zero-extended byte to long" and is saying to extend ecx into 32 bits, but I'm not entirely sure what the syntax (%rdi, %rcx, 1) refers to.

意思是“移动零扩展字节”,并表示将ecx扩展到32位,但我不完全确定语法(%rdi, %rcx, 1)是指什么。

I've seen somewhere that that syntax refers to

我在某个地方见过这种语法。

(Base, Index, Scale)

but I can't find any resources that say what that means exactly. I'm guessing it means to move whatever info is at (%rdi, %rcx, 1) to %ecx so that

但是我找不到任何资源来说明这到底意味着什么。我猜它的意思是移动任何信息(%rdi, %rcx, 1)到%ecx。

(long) %ecx = (%rdi, %rcx, 1)

but how do I figure out what location that is? is there some sort of arithmetic involved to find an address or something?

但我怎么算出哪个位置呢?是否有某种算法涉及到找到地址之类的?

also isn't ecx implicitly 32 bits already? Why would it need to be extended into 32 bits?

ecx是否已经隐式32位了?为什么需要扩展到32位?

edit for clarification:

编辑说明:

I understand that the syntax (%rdi, %rcx, 1) means that I have to add those three things together, but I don't understand how that results in an answer.

我知道语法(%rdi, %rcx, 1)意味着我必须将这三样东西加在一起,但是我不理解这是如何产生答案的。

What am I adding, the contents of the registers? The address of the register? If it's the address, how do I figure out what the address is and add it together?

我添加了什么,寄存器的内容?登记册的地址?如果是地址,我怎么知道地址是什么,把它加在一起?

All I'm finding online is telling me what the syntax means but not how to use it with examples.

我在网上找到的只是告诉我语法的含义,而不是如何用实例来使用它。

1 个解决方案

#1


1  

To quote the intel basic architecture manual:

引用英特尔基本架构手册:

3.7.5 Specifying an Offset 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:

3.7.5指定抵消部分的内存地址可以直接指定为静态值(称为位移)或通过一个或多个以下组件组成的地址计算:

  • Displacement -- An 8-, 16-, or 32-bit value.
  • 位移——一个8、16或32位的值。
  • Base -- The value in a general-purpose register.
  • Base——通用寄存器中的值。
  • Index -- The value in a general-purpose register.
  • 索引——通用寄存器中的值。
  • Scale factor -- A value of 2, 4, or 8 that is multiplied by the index value.
  • 比例因子——值为2、4或8,乘以指数值。

The offset which results from adding these components is called an effective address.

添加这些组件的结果被称为有效地址。

Notice it says "the value in a general-purpose register". As registers are not part of the memory address space on x86, they don't even have an address, so the only thing you can possibly use is the value in them.

请注意它表示“通用寄存器中的值”。由于寄存器不是x86的内存地址空间的一部分,所以它们甚至没有地址,所以您唯一可以使用的就是它们的值。

As for the movzbl: it instructs the cpu to fetch a byte from memory, and zero extend it to 32 bits.

至于movzbl:它指示cpu从内存中获取一个字节,0将其扩展到32位。

#1


1  

To quote the intel basic architecture manual:

引用英特尔基本架构手册:

3.7.5 Specifying an Offset 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:

3.7.5指定抵消部分的内存地址可以直接指定为静态值(称为位移)或通过一个或多个以下组件组成的地址计算:

  • Displacement -- An 8-, 16-, or 32-bit value.
  • 位移——一个8、16或32位的值。
  • Base -- The value in a general-purpose register.
  • Base——通用寄存器中的值。
  • Index -- The value in a general-purpose register.
  • 索引——通用寄存器中的值。
  • Scale factor -- A value of 2, 4, or 8 that is multiplied by the index value.
  • 比例因子——值为2、4或8,乘以指数值。

The offset which results from adding these components is called an effective address.

添加这些组件的结果被称为有效地址。

Notice it says "the value in a general-purpose register". As registers are not part of the memory address space on x86, they don't even have an address, so the only thing you can possibly use is the value in them.

请注意它表示“通用寄存器中的值”。由于寄存器不是x86的内存地址空间的一部分,所以它们甚至没有地址,所以您唯一可以使用的就是它们的值。

As for the movzbl: it instructs the cpu to fetch a byte from memory, and zero extend it to 32 bits.

至于movzbl:它指示cpu从内存中获取一个字节,0将其扩展到32位。