简体   繁体   中英

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.

Here is my thought process:

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

However, the actual if statement in the code is the exact opposite. I know it has something to do with how in assembly, the conditional executed is the reverse...therefore it makes a[idx] > *b instead. Does this have to do with "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. The jle is "jump if less than or equal" so it's become the equivalent of the C#:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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