我可以将 64 位常量添加到 64 位寄存器吗? [英] Can I add 64bit constants to 64bit registers?

查看:15
本文介绍了我可以将 64 位常量添加到 64 位寄存器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 64 位英特尔机器上,以下代码有效:

At my 64bit Intel machine following code works:

mov rdi, 1 << 40
add r10, rdi

而这个看起来相当类似的会产生警告并且不起作用:

and this quite equivalent looking one produces a warning and doesn't work:

add r10, 1 << 40

我应该坚持第一还是我错过了什么?这种行为似乎很尴尬.

Should I just stick with number 1 or am I missing something? This behaviour seems akward.

代码 nr 2 产生的警告:

The warning produced by code nr 2:

warning: signed dword immediate exceeds bounds

推荐答案

mov r/m64, imm64 有操作码,但 add r/m64 没有操作码,imm64 在 x86-64 指令集中.换句话说:您不能对 add 使用 64 位立即数操作数,但可以为 mov 使用(有许多指令没有 imm64 变体;您可以查看英特尔软件开发人员手册中的指令集参考,以检查哪些指令具有此类变体,哪些没有).

There is an opcode for mov r/m64, imm64, but there is no opcode for add r/m64, imm64 in the x86-64 instruction set. In other words: you cannot use 64-bit immediate operand for add, but you can for mov (there are many instructions that don't have the imm64 variant; you can check the Instruction Set Reference in the Intel Software Developer Manual to check which instructions have such variant and which don't).

这篇关于我可以将 64 位常量添加到 64 位寄存器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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