在x86 / x64添加位移寻址 [英] x86/x64 Add Displacement addressing

查看:271
本文介绍了在x86 / x64添加位移寻址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写的x86 / x64的CPU指令编译器,我似乎无法弄清楚什么人用'位移'地址的意思。例如添加指令在这里详细介绍:
http://www.c-jump.com/CIS77/CPU/x86/X77_0150_encoding_add_edx_displacement.htm

I'm writing a compiler for x86/x64 CPU instructions and I can't seem to figure out what people mean by 'displacement' address. For example the Add instruction is detailed here: http://www.c-jump.com/CIS77/CPU/x86/X77_0150_encoding_add_edx_displacement.htm

我只是想实现其中寄存器被添加到一个正常的内存地址加法指令。问题是,该地址是位移地址。这是否意味着该地址是一个符号值这就是从指令位置偏移?

I'm just trying to implement the add instruction where a register is added to a normal memory address. The problem is, the address is a 'displacement address'. Does that mean the address is a signed value that's the offset from the instruction location?

推荐答案

有在86几个不同形式的间接操作数的:

There are a few different forms of indirect operands in x86:


  1. [注册]

  2. [注册+排量]

  3. [位移]

  4. [注册* +不变章]

  5. [注册*常量+ +章排量]

的位移是只是被添加到该地址的其余的常数。在那里没有比恒定其他地址的组件的情况下,它仍称为位移​​。这主要是为了与其他寻址方式的一致性。

The "displacement" is just a constant that gets added to the rest of the address. In cases where there is no component of the address other than the constant, it is still called a "displacement". This is mainly for consistency with the other addressing forms.

看它的另一种方式是,所有地址形式

Another way to look at it is that all addresses are of the form

[注册*常量+ +章排量]

[reg * constant + reg + displacement]

对于每个允许值为0的组件。

With each of the components allowing a value of 0.

在[位移]的形式仅仅是编码,其中除排量以外的所有成分均为零。

The [displacement] form is just the encoding where all components other than the displacement are zero.

由于编译器作者在过去的2形式是特别有趣。他们可以很容易地连接如粒子阵列[指数] code的事情 - 方式>场+ 1 在一个指令

As a compiler writer the last 2 forms are particularly interesting. They make it easy to encode things like pArray[index]->field + 1in a single instruction.

这篇关于在x86 / x64添加位移寻址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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