How does conditional jump of x86-64 works?
How does conditional jump of x86-64 works?
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 Answer
1
There's no compq in x86-64. There's CMP which will be cmpq when comparing 64-bit operands in AT&T syntax.
compq
cmpq
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
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
(long int)rax < (long int)rdi
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
This will jump when
(long int)rax < (long int)rdi.– Aki Suihkonen
Sep 16 '18 at 14:13