Hello and welcome back.
In this lesson, we are going to take a look at how to zero out a register.
So let's open our template.
And then go down and hollow out this section.
Now take a look at register -.
If you want to empty this register, make it all zeros.
We can use the XOR instruction.
So just type "XOR -, -"
and click "OK."
Now when you run it, put a breakpoint first and then step over.
Then when you step over this instruction, watch what happens to the register.
It becomes zero.
So let's try that for -.
So over here,
we "XOR -, -."
OK, now we are going to step over this and see -. Step over. - also becomes zero.
So you can use this simple way to zero out any register you want.
Of course, you can also use MOV.
For example, you could "MOV -," let's say, "0x0" to -.
And then step over and watch
-.
- will become zero, but there is a difference.
XOR uses only three bytes, but MOV uses 1, 2, 3, 4, 5 bytes.
So XOR is shorter,
a shorter instruction.
So preferably we use XOR because it's only three bytes.
So that's all for this lecture.
Thank you for watching.