将32位寄存器移至8位寄存器 [英] Move 32bit register into a 8 bit register

查看:141
本文介绍了将32位寄存器移至8位寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将edx移至al,但出现此错误

Im trying to move edx into al but i get this error

lib/io/print.asm:50: error: invalid combination of opcode and operands

这是代码

mov edx, 0x41
mov al, edx

预先感谢

推荐答案

问题是第二行:

mov al, edx

edx寄存器是32位,但是al是8位,因此您不能直接将一个移到另一个.如果要将edx的低8位移到dl中,请执行以下操作:

The edx register is 32-bits, but al is 8-bit, so you can't directly move one into the other. If you want to move the low 8 bits of edx into dl, do this:

mov al, dl

或者您可能想将所有edx移到eax中,像这样:

Or perhaps you want to move all of edx into eax, like this:

mov eax, edx

区别在于第一个选项将eax的高24位保持不变,而第二个选项将它们设置为与edx的相应位相同.

The difference is the first option leaves the high 24 bits of eax unchanged, while the second option sets them to the same as the corresponding bits of edx.

如果您不关心高24位,例如,因为您将不使用它们,或者因为您知道它们在两种情况下均为零,则第二种选择可能会稍快一些,因为它会破坏依赖性在eax的先前值上执行,因此无论eax之前发生了什么,它都可以在edx准备好后立即执行.

If you don't care about the high 24 bits, e.g., because you aren't going to use them, or because you know they are zero in either case, the second option may be slightly faster because it breaks the dependency on the previous value of eax, so it can execute as soon as edx is ready, regardless of what happened to eax before.

这篇关于将32位寄存器移至8位寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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