Hello and welcome back.
In this lesson, we are going to take a look at the practical for the XOR operations.
And the syntax for XOR operation is: XOR destination, source.
And these are two examples.
So first, let's put the breakpoint in our template file, which is template 2x, at this location.
And then we'll run and hit our breakpoint,
and we step over until we come to this line.
So here is where we are going to move our initial value to the - register.
So we use -.
And let's type a move here.
Move -,
12345678.
Okay.
Let's say we put this in the - register.
So this is the value you want to put to register.
I just copy and paste here so you have a copy.
Hit okay.
And now we step over, and now B3 is in - register.
So this is B3 in hex.
And we can confirm that with our calculator.
Go to hex and type B3.
And we see this value here.
Same.
Now we are going to do something unique.
We are going to XOR - with itself.
So XOR - with -.
See what happens.
So we are referring to the second one here, XOR with itself.
So when we run this, watch what happens to this.
It becomes zero.
So this is a very special characteristic of XOR.
When you XOR any register with itself, you zero out the register.
Now this is very often used in the assembly code because it is more efficient than moving zero to the
register.
It consumes less bytes.
So take note of that.
Now, let's do something else.
Let's move back this value into the - register.
Step over.
And now we get back our B3.
So now we are going to do another something else which is rather unique.
We are going to XOR the register with all ones.
So XOR - with all ones.
So there are eight bits here of one.
Eight ones.
Okay.
Okay, so we are going to XOR with all ones.
Let me check that.
Sorry, this should be 0b.
All right.
So when you convert all ones to hex, it is FF.
So let's try this and see what happens.
This is the original bit.
And now we are going to XOR it with all ones.
And we get 4C.
So what is 4C in binary?
So let's open a calculator.
So we can go to hex first. Type 4C.
And we see that it is 01001100.
This value here.
Now what is the significance of that?
Take a look.
We copy and paste it here.
Notice every bit in the original number has been flipped.
So one became zero.
Zero became one.
See that?
So there is a significance of XORing any number with all ones.
The effect is to flip all the bits.
Okay.
So this is an example of the register and immediate, and register and register, and also some
characteristics of XOR: register with itself, and also XOR of register with all ones.
So that's all for this video.
Thank you for watching.