简体   繁体   English

条件标记程序集-CMP,测试

[英]Conditional Flags Assembly - cmp, test

I'm having a hard time understanding conditional code in assembly. 我很难理解汇编中的条件代码。 The assembly on the right is for funA() on the left, but I'm having trouble with lines 3-4 in assembly. 右边的程序集用于左边的funA(),但是我在汇编程序的3-4行时遇到了麻烦。

Here is my thought process: 这是我的思考过程:

cmp rax, rcx // a[idx] <= *b

However, the actual if statement in the code is the exact opposite. 但是,代码中实际的if语句恰恰相反。 I know it has something to do with how in assembly, the conditional executed is the reverse...therefore it makes a[idx] > *b instead. 我知道它与汇编的方式有关,条件执行的过程是相反的……因此它使a [idx]> * b相反。 Does this have to do with "jle"? 这和“ jle”有关吗? Would someone mind explaining this to me? 有人介意向我解释吗?

在此处输入图片说明 在此处输入图片说明

If you look at .L1 and .L2, the JIT compiler has just decided to reverse the order - it's put the else code first, and reversed the condition. 如果查看.L1和.L2,则JIT编译器刚刚决定反转顺序-将else代码放在第一位,并反转了条件。 The jle is "jump if less than or equal" so it's become the equivalent of the C#: jle是“如果小于或等于则跳转”,因此它等效于C#:

if (a[idx] <= *b)
{
    *b = *b + *b;
}
else
{
    *b = a[idx];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM