CAN" MOV EAX,为0x1"始终可以用来代替" MOV RAX,为0x1&QUOT ;? [英] Can "mov eax, 0x1" always be used instead of "mov rax, 0x1"?

查看:1305
本文介绍了CAN" MOV EAX,为0x1"始终可以用来代替" MOV RAX,为0x1&QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此组装code与 NASM

BITS 64
mov eax, 0x1
mov rax, 0x1

我得到这样的输出:

I get this output:

b8 01 00 00 00 b8 01 00 00 00

这是运code为 MOV EAX,为0x1 重复两次。

这是否意味着 MOV RAX,为0x1 可以总是 MOV EAX更换,为0x1 或只是在这种情况下?

Does this mean that mov rax, 0x1 can always be replaced by mov eax, 0x1 or is it just in this case?

如果这是正确的,那岂不是比使用方法:

If this is correct wouldn't it be better to use than:

xor rax, rax
inc rax

当组装而 MOV EAX,为0x1 只有5个字节变为6个字节?

as that becomes 6 bytes when assembled while mov eax, 0x1 is only 5 bytes?

推荐答案

始终。大部分(如果不是全部),32位的MOV和ALU操作清晰bit 32到目标寄存器操作数的63。详情请参阅CPU手册。

Always. Most (if not all) 32-bit MOVs and ALU operations clear bits 32 through 63 of the destination register operand. See the CPU manual for details.

这篇关于CAN" MOV EAX,为0x1"始终可以用来代替" MOV RAX,为0x1&QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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