x86_64 Cannot add 64 bit value to rax, “operand mismatch on 'add'”

后端 未结 1 1077
有刺的猬
有刺的猬 2021-01-28 13:16

I am trying to assemble some 64-bit code and the assembling fails on the line:

addq $0xffffff7fc0005000, %rax

with the error:

相关标签:
1条回答
  • 2021-01-28 13:23

    The first operand is a 64bit value and the latter a register which should assemble fine.

    It shouldn't, the 64bit version of add can take an 8bit or 32bit sign-extended immediate, but not a 64bit immediate, which in general is rare in x64. This can be verified by looking in the Intel Software Developer's Manual or various other places, such as this online copy of the ADD lemma.

    You could mov (or movabs as GAS likes to call this variant) a 64bit immediate into a register and then use that, or put the value in memory and use it in an add with a memory operand.

    0 讨论(0)
提交回复
热议问题