x86-64 的条件跳转是如何工作的? [英] How does conditional jump of x86-64 works?
本文介绍了x86-64 的条件跳转是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在学习 x86-64 时对条件分支非常困惑.
I'm so confused about conditional branch while I was studying x86-64.
compq %rax,%rdi
jl .L2
正确的理解是?
- 如果 %rax <%rdi,跳转到 L2
- 如果 %rax > %rdi,跳转到 L2
推荐答案
x86-64 中没有 compq
.有 CMP 在比较 64 位时将是 cmpq
AT&T 语法中的操作数.
There's no compq
in x86-64. There's CMP which will be cmpq
when comparing 64-bit operands in AT&T syntax.
使用 Intel 语法时会更清楚,因为 AT&T 交换了目的地和来源,这将是 更容易混淆cmp
和sub
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 指令 总是将第一个操作数与第二个操作数进行比较.在这种情况下,它会在 rdi <时跳转.拉克斯
Jcc instructions always compare the first operand with the second one. In this case it'll jump when rdi < rax
这篇关于x86-64 的条件跳转是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文