MOV r/m8,r8 和 MOV r8,r/m8 的区别 [英] Difference between MOV r/m8,r8 and MOV r8,r/m8

查看:91
本文介绍了MOV r/m8,r8 和 MOV r8,r/m8 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过查看英特尔指令量,我发现了这一点:

By looking at intel volume of instructions, I found this:

1) 88/r ​​MOV r/m8,r8
2) 8A/r MOV r8,r/m8

当我在 NASM 中写这样一行,并用列表选项组合它时:

When I write a line like this in NASM, and assemble it with the listing option:

mov al, bl

我在列表中得到了这个:

I get this in the listing:

88D8 mov al, bl

那么显然 NASM 选择了上面两条指令中的第一条指令,但第二条指令不是选项二吗?如果是这样,NASM是根据什么选择第一个的?

So obviously NASM chosed the first instruction of the two above, but isn't the second instruction an option two? if so, on what basis did NASM chosed the first?

推荐答案

存在这两种编码是因为一个 modr/m 字节只能编码一个内存操作数.因此,要同时允许 mov r8,m8mov m8,r8,需要两种编码.当然,通过这种方式,我们可以对 mov 的使用进行编码,两个操作数都是使用编码的寄存器,而 nasm 只是随机选择一个.选择没有特别的理由,我已经看到组装者做出了不同的选择.

These two encodings exist because a modr/m byte can only encode one memory operand. So to allow both mov r8,m8 and mov m8,r8, two encodings are needed. Of course, this way we can encode uses of mov with both operands being registers using either encoding and nasm just picks one at random. There is no special reason for the choice and I have seen assemblers make different choices.

我还听说过一个汇编器,它通过以特定方式选择指令编码来为它汇编的二进制文件添加水印.这样,汇编程序的作者就可以追查并起诉使用他的汇编程序而无需付费的人.

I have also heard about an assembler that watermarked binaries it assembles by choosing an instruction encoding in a specific way. This way the author of the assembler could track down and sue people who used his assembler without paying.

这篇关于MOV r/m8,r8 和 MOV r8,r/m8 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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