I try to add some values in assembler (AMD AT&T syntax). But I have problems with big immediate values (> 32bit).
.globl f
.type f, @function
f:
movq %rdi, %r10
addq $0x0000000000000008, %r10 # no problem
addq $0x0000000122446688, %r10 # error
movq %r10, %rax
ret
The marked line returns the following gcc-error:
Error: operand type mismatch for `add'
But addq should be able to handle this number:
0000000122446688(hex) = 4869875336(dec)
and log2(4869875336) ~ 33bit (which is much smaller than 64bit).
ADD
doesn't take a 64 bit immediate, there is only a version that accepts a 32 bit sign extended one and your second constant doesn't fit that constraint. See the instruction set reference.
Note: the q
suffix specifies operation size, not the size of the immediate. It is a 64 bit addition, but the operand is encoded as 8 or 32 bit sign-extended immediate.