0

I am trying to write 64 bit cmp within inline assembly following the last version of CMP at [1]. Currently I have the following.

int main() {
  asm("cmpl $0x0011001100110011, %rdi");
}

But I get the following error.

incorrect register `%rdi' used with `l' suffix

What should be the correct format to encode this instruction?

[1] http://www.felixcloutier.com/x86/CMP.html

chamibuddhika
  • 1,419
  • 2
  • 20
  • 36
  • Maybe you mean to use `cmpq` and do you mean hex `$0x0011001100110011` or binary `$0b0011001100110011` ? – Michael Petch Sep 29 '16 at 05:52
  • If you in fact want to compare a full 64-bit value then you could do `movq $0x0011001100110011, %rax` and then `cmpl %rax, %rdi` – Michael Petch Sep 29 '16 at 06:06
  • I meant to use cmpq (my bad) with the hex value. So asm("cmpq $0x0011001100110011, %rdi"); wouldn't work as well apparently. – chamibuddhika Sep 29 '16 at 06:36
  • 4
    If you review the instruction set that you linked to there is no _CMP_ that takes a 64-bit register (r64) and a 64-bit immediate (imm64) value. You either have to _MOV_ to get a 64-bit immediate value (imm64) in a 64-bit register (r64) and then compare that register with _RDI_, or you can use _CMP_ with _RDI_ and a 64-bit value as a memory operand (m64). – Michael Petch Sep 29 '16 at 06:45

0 Answers0