Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add 64bit constants to 64bit registers?

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.

The warning produced by code nr 2:

warning: signed dword immediate exceeds bounds
like image 666
user1864035 Avatar asked Nov 16 '13 16:11

user1864035


People also ask

Are there 64-bit registers?

x64 extends x86's 8 general-purpose registers to be 64-bit, and adds 8 new 64-bit registers. The 64-bit registers have names beginning with "r", so for example the 64-bit extension of eax is called rax. The new registers are named r8 through r15.

Is RAX a 64-bit register?

rax is the 64-bit, "long" size register. It was added in 2003 during the transition to 64-bit processors. eax is the 32-bit, "int" size register. It was added in 1985 during the transition to 32-bit processors with the 80386 CPU.


1 Answers

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).

like image 81
Griwes Avatar answered Sep 27 '22 15:09

Griwes