开发者

How does the JE instruction work without CMP?

开发者 https://www.devze.com 2023-03-31 01:50 出处:网络
.L10: leal(%rsi,%rsi,4), %edx movsbl%al,%eax addq$1, %rdi leal-48(%rax,%rdx,2), %esi je开发者_开发技巧.L3
.L10:
    leal    (%rsi,%rsi,4), %edx
    movsbl  %al,%eax
    addq    $1, %rdi
    leal    -48(%rax,%rdx,2), %esi
    je  开发者_开发技巧.L3

In the above there's no cmp preceding je. How does it work here?


  • je will jump is ZF = 1.
  • add modifies the ZF.
  • lea, movsb does not affect any flags.

Keep the Intel 64 and IA32 Architecture Developer's Manual in hand. You can find all the instruction details of Intel 64 and IA32 architecture in the manual Volume 2


je jumps if the ZF flag is set in the EFLAGS register. The value of the ZF flag is set by the previous (for example cmp) operation that modified it.

Since neither lea nor movsbl modify the ZF flag, but add does (compare Intel Developer's Manual, 3-36), je jumps to .L3 iff $1 + %rdi is zero.


The preceding instruction sets a processor status flag. Each conditional jump checks a certain flag, even if a cmp was not executed. I believe je executes if the zero flag is set.

0

精彩评论

暂无评论...
验证码 换一张
取 消