Hello and welcome back.
In this lesson, we are going to take a look at signed conditional jumps.
So for signed conditional jumps, we are also going to use the compare instruction.
But this time we are going to compare signed numbers instead of unsigned numbers.
So in the same way, we also can compare something with another number, another value here.
And then based on that, we also will jump or not jump accordingly.
So JL means jump if less than. That means if the first parameter is less than the second one,
then it will jump.
JLE means jump if less or equal. It means that if the first parameter is less than or equal to the
second one, then it will jump.
On the other hand, JG means jump if greater. So in this case, if the first parameter
is greater than the second parameter, it will jump. And JGE means jump if greater than or equal.
So if the first parameter is greater than or equal to the second one, then it will jump.
So let's take a look at this
inside the template2, which I have opened in x64dbg.
So I put a breakpoint here.
And now I'm going to move some values into - and some into as an immediate.
So let's say I move negative one into -, I hit okay.
So negative one is
converted into hex will be all Fs.
And then now I am going to move another value in -.
So I'm going to move - and I'm going to move negative two.
Negative two in -.
So negative two converted to hex is this value here ending with E.
You can confirm this by opening a calculator, as we have done before, and check to make sure that
it is correct.
So now I'm going to put in the decimal, negative one.
Select one and put negative in here.
And you will see negative one is all Fs like this.
Then I clear.
Now I'm going to put two and I'm going to change the sign.
Negative two.
Negative two is all Fs ending with an E like this.
So this is negative one.
This is negative two.
So now let's take a look at the compare and JL.
So I'm going to put JL.
But let's select a place to jump to.
Maybe I jump here or here.
So copy this address.
And then over here put JL and, before I can do that, I need to compare.
So I forgot this step.
So excuse me.
So we need to compare - and -.
Then we put JL and paste the address that you want to jump to.
Okay, so now we are going to run to hit our breakpoint.
And we step over and we move negative one to -.
And then we move negative two to -.
So we are comparing two registers.
So now it's going to compare - and - and see what happens.
We step over.
And then now we're going to come to this line. - is bigger than -.
So in this case, it will not jump because JL only will jump if - is less than -.
JL will only jump if - is less than -.
So in this case, because - is negative one, it is larger than -, which is negative two.
Therefore, it won't jump.
That's why you see the arrow is grayed out instead of red in color.
So if you step over, you can see that it continues straight.
Okay, now let's do another test.
We put this time JG.
JG, and we paste the same address and see what happens.
So in this case, you will see that it will jump because - is indeed larger than -.
Therefore, jump if greater is true.
So it will jump.
So it will jump to this location here.
So the same way, JLE and JGE also work in a similar way.
It's just that JLE means that it will jump if equal as well, and JGE also jumps if equal.
So for that, let's try. We are going to reset everything.
This time we are going to move a value of negative three into -.
And we are also going to move the value negative three into -.
Negative three.
Then we run to our breakpoint and we step over and we move the two values, one into - and one to
-.
So both are negative three.
And you can use your calculator to confirm that in the way that I taught you earlier.
So now we are going to do a comparison, CMP - and -.
And then after the comparison, we are going to do a jump if less than or equal to, and then we're
going to paste our address.
Like this.
So now we step over and let it do the comparison.
And now it comes to this.
JLE, you notice the red arrow lights up, meaning that it will jump.
Why?
Because - and - are equal.
And this is testing whether they are less than or equal.
So since they are equal, it will jump.
So the same way also applies to JGE. JGE, yes.
So we can try that. Reset now and then we go and put -.
We put negative two into -, and then we put
also negative two into -.
And then we compare
- with -.
And then
now we're going to put JGE.
And paste our address.
Okay.
Let's run now to hit our breakpoint and step over.
And now we compare - and -, and they are equal.
And you notice when you come to the JGE,
the arrow lights up in red, meaning that it will jump, and it's also shown here.
Jump is taken.
So why is that?
Because JGE is true.
It will jump if it's greater than or equal.
So in this case, because - and - are equal,
so it will jump.
Okay.
So this is how we can use the conditional jump.
So this JL, JLE, JG, JGE are used for testing signed jumps.
The signed jumps means that the values are negative, have negative numbers.
That means you are treating the numbers here as negative or positive numbers.
The previous one where we did JE and JNE,
those are for unsigned numbers.
So that's the difference between the two.
So that's all for this video.
Thank you for watching.