简体   繁体   中英

Invalid operand for instruction

I'm using inline x64 assembly with Intel Compiler, i'm trying to add a huge value to an rbp register, the compiler gives me an error that the operand is incorrect for that huge of a 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
           ^

No, there is no such opcode which can do on that way: However there is a single opcode that can do that:

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

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

    mov   rax, 0x7ffffffffffffff0
    add   rbp, rax   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM