【问题标题】:How does conditional jump of x86-64 works?x86-64 的条件跳转是如何工作的?
【发布时间】:2018-09-16 10:13:40
【问题描述】:

我在学习 x86-64 时对条件分支感到很困惑。

compq %rax,%rdi
jl .L2

哪个是正确的理解?

  1. 如果 %rax
  2. 如果 %rax > %rdi,跳转到 L2

【问题讨论】:

    标签: assembly x86 x86-64 att conditional-execution


    【解决方案1】:

    x86-64 中没有 compq。在比较 AT&T 语法中的 64 位操作数时,CMP 将是 cmpq

    使用 Intel 语法会更清楚,因为 AT&T 交换了目标和源,即more confusing on instructions like cmp and sub

    cmp rdi, rax
    jl .L2
    

    Jcc instructions 总是将第一个操作数与第二个操作数进行比较。在这种情况下,当 rdi

    【讨论】:

    • 这会在(long int)rax < (long int)rdi时跳转。
    猜你喜欢
    • 2017-12-28
    • 2022-12-11
    • 1970-01-01
    • 2011-03-11
    • 2016-01-21
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多