了解指令编码? [英] Understanding Instruction Encoding?

查看:36
本文介绍了了解指令编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一个网站来对此进行编码:

I used a website to encode this:

movw $8, 4(%r8d,%esi,4)

并得到:

encoding (hex): 67 66 41 C7 44 B0 04 08 00

多亏了你,我几乎明白了除了 2 个小点之外的一切:

Thanks to you I nearly understand everything except 2 small points:

  1. 这里我们将 2 个字节的立即数移动到 4 个字节的地址.他们使用了 C7 操作码,根据我的表格,它意味着以下之一:

  • 将 imm16 移动到 r/m16
  • 将 imm32 移动到 r/m32
  • mov imm32(符号扩展)到 r/m64
  • 为什么没有匹配?

    1. 为什么立即数是 2 个字节?根据什么?

    推荐答案

    有一个匹配项.这是第一个mov imm16 to r/m16",因为助记符movw中有w.r/m16 表示正在读取/写入 16 位(两个字节)的内存.碰巧您使用 32 位有效地址来标识要写入的内存的哪两个字节,但这不是 r/m16 符号的一部分.

    There is a match. It's the first one "mov imm16 to r/m16", because of the w in the mnemonic movw. r/m16 means that 16 bits (two bytes) of memory are being read/written. It so happens that you are using a 32-bit effective address to identify which two bytes of memory are to be written, but that's not part of the r/m16 notation.

    立即数是两个字节,因为要写入两个字节.拥有更多是没有意义的.虽然有一些例子,比如第三种情况,其中立即数比操作数的大小短,并且是零或符号扩展.

    The immediate is two bytes because two bytes are to be written. There would be no point in having more. Though there are some examples, like the third case, where the immediate is shorter than the operand size and is zero- or sign-extended.

    这篇关于了解指令编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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