Search code examples
assemblycomparearguments64-bitcmp

Compare two arguments ASM x64


Someone can tell me how to compare two arguments (RDI and RSI) in ASM x64 ?

I have a problem on compilation when I use:

cmp byte[rdi+rax],byte[rsi+rax]

I'm getting an error:

"error: invalid combination of opcode and operands"

Solution

  • cmp instruction, like the majority of x86/x86-64 instructions, allows at most one memory operand. So, to compare contents of two memory locations, you need to load at least one of them into a register:

    mov cl, byte[rdi+rax]
    cmp cl, byte[rsi+rax]