I\'m trying to compile the following assembly...
movq $0x3534373536383235, 0x000000000055638f8
movq $0x55638f8, %rdi
retq
The first
One way to do it is:
movabsq $0x3534373536383235, %rax
movabsq %rax, 0x000000000055638f8
As the other comment says, you can't move a 64 bit immediate to a 64 bit memory address because there is no instruction that allows you to do this. This opcode is missing because opcodes cannot currently exceed 15 bytes, and the two 64 bit values alone are 16 bytes, and would have to be part of the opcode. This limitation applies to smaller opcodes that would become too large with prefixes as well. Because you are moving to an absolute 64 bit memory address, you will want to use movabs or movabsq, whichever your assembler likes.
If you look in the manual under the lemma MOV
(which is, admittedly, a bit intimidating), you will find that there is no mov r/m64, imm64
.
There's a way to load a full 64bit constant into a register, and there's a way to load a sign-extended 32bit constant into a 64bit memory location, but there is no single instruction that takes a 64bit immediate and writes it to memory.
So you have to do it in two steps, such as by using a temporary register or by writing two dwords straight to memory separately.