Reputation: 41
If part of the assembly code is as following:
xor %ebp,%ebx
jle some address
does this jle means that it will jump when (%ebx ^ %ebp == 0) because that would set ZF to 1?
Upvotes: 4
Views: 648
Reputation: 365332
That's one of the ways JLE can be true. The other is SF≠ OF
, as per the manual:
https://www.felixcloutier.com/x86/jcc
Since XOR always clears OF, SF != OF
reduces to just SF.
jle
after a boolean op will be taken if SF | ZF
, i.e. if the result is <= 0
.
Interesting optimization to avoid test %ebx,%ebx
to compare the result against zero (AND or TEST same,same sets FLAGS identically to cmp reg,0
).
Upvotes: 5