assemblyvisual-c++x86-64icc

Invalid operand for instruction


I'm using inline x64 assembly with the Intel Compiler, and I'm trying to add a huge value to the RBP register.

The compiler gives me an error, saying that the operand is incorrect for that huge number. Is there a way to solve this?

My code:

__asm add rbp, 0x7FFFFFFFFFFFFFF0
__asm and rbp, 0x7FFFFFFF

The compiler outputs this:

ld-link: : error : ld-temp.o <inline asm>:2:2: invalid operand for instruction
           add rbp, 3264300659
           ^

Solution

  • No, there is no opcode that can do it in that way!
    However there is a single opcode that can do the following:

    BigConstant = 0x7ffffffffffffff0
    ...
    ...
    add   rbp, qword ptr BigConst  //48 03 2D xx xx xx xx
    

    You could also use an extra register to solve the problem, like:

    mov   rax, 0x7ffffffffffffff0
    add   rbp, rax