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

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

问题描述

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

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

我应该坚持使用数字1还是错过什么?这种行为似乎很笨拙.

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

推荐答案

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

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天全站免登陆