[ebp * 2]是否引用DS或SS段? [英] Does [ebp*2] reference DS or SS segment?

查看:133
本文介绍了[ebp * 2]是否引用DS或SS段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IDM说,如果将EBP用作基址寄存器,则存储器op将使用SS段.结果,[ebp + esi][esi + ebp]分别引用SS和DS段.请参阅NASM的文档: 3.3有效地址.

IDM says the memory op uses SS segment if EBP is used as base register. As a result, [ebp + esi] and [esi + ebp] references SS and DS segments, respectively. See NASM's doc: 3.3 Effective Address.

在同一部分中,NASM提到了如何通过将[eax*2]替换为[eax+eax]来生成较短的机器代码.

In the above same section, NASM mentioned how to generate shorter machine code by replacing [eax*2] with [eax+eax].

但是,NASM也会为[ebp*2]生成[ebp + ebp](即没有基址寄存器).

However, NASM also generates [ebp + ebp] for [ebp*2] (i.e. no base register).

我怀疑[ebp+ebp]引用了SS段,而[ebp*2]引用了DS段.

I suspect [ebp+ebp] references SS segment, and [ebp*2] references DS segment.

我问了NASM这个问题.他们认为[ebp*2][ebp+ebp]是相同的,但是对我来说这没有意义.显然,[ebp+ebp](ebp作为基址寄存器)引用SS段.如果它们相同,则[ebp*2也必须引用SS.这意味着只要ebp是基址或索引寄存器,就引用SS,这又意味着[ebp + esi][esi + ebp]都引用SS段,因此它们必须相同.

I asked NASM this question. They think [ebp*2] and [ebp+ebp] are the same, but it doesn't make sense to me. Obviously, [ebp+ebp] (ebp as base register) references SS segment. If they're the same, [ebp*2 must reference SS too. This means SS is referenced as long as ebp is the base or index register, which in turn means, both [ebp + esi] and [esi + ebp] reference SS segments, so they must be the same.

有人知道[ebp*2]使用哪个细分市场吗?

Does anyone know which segment [ebp*2] uses?

推荐答案

英特尔手册在下面的图3-11中告诉我们,该图处理Offset = Base + (Index * Scale) + Displacement:

The Intel manual tells us below figure 3-11, which deals with Offset = Base + (Index * Scale) + Displacement:

通过以下方式限制将通用寄存器用作基本或索引组件:

The uses of general-purpose registers as base or index components are restricted in the following manner:

  • ESP寄存器不能用作索引寄存器.
  • 当ESP或EBP寄存器用作 base 时,SS段是默认段.在所有其他情况下,DS细分是默认细分.
  • The ESP register cannot be used as an index register.
  • When the ESP or EBP register is used as the base, the SS segment is the default segment. In all other cases, the DS segment is the default segment.

这意味着当NASM将[ebp*2]更改为[ebp+ebp]时,它是错误的(以避免32位位移).

This means that NASM is wrong when it changes [ebp*2] into [ebp+ebp] (in order to avoid the 32bit displacement).

[ebp*2]使用DS是因为ebp不是用作基础
[ebp+ebp]使用SS是因为ebp之一被用作基础

[ebp*2] uses DS because ebp is not used as base
[ebp+ebp] uses SS because one of the ebp is used as base

然后最好指定您不希望NASM出现此行为.
在NASM作者意识到错误之前,您可以通过以下操作禁用此行为(其中EBP用作索引):

It would then be best to specify that you don't want this behaviour from NASM.
Until the time NASM authors realize their mistake, you can disable this behaviour (where EBP is used as an index) by writing:

[NoSplit ebp*2]

这篇关于[ebp * 2]是否引用DS或SS段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆