0

I'm so confused about conditional branch while I was studying x86-64.

compq %rax,%rdi
jl .L2

Which one is the correct understanding?

  1. if %rax < %rdi, jump to L2
  2. if %rax > %rdi, jump to L2
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
김동령
  • 3
  • 2

1 Answers1

1

There's no compq in x86-64. There's CMP which will be cmpq when comparing 64-bit operands in AT&T syntax.

It'll be clearer when using Intel syntax, because AT&T swaps the destination and source which will be more confusing on instructions like cmp and sub

cmp rdi, rax
jl .L2

Jcc instructions always compare the first operand with the second one. In this case it'll jump when rdi < rax

phuclv
  • 37,963
  • 15
  • 156
  • 475