WEBVTT

00:01.240 --> 00:02.650
Hello and welcome back.

00:02.650 --> 00:07.930
In this lesson, we are going to take a look at how to zero out a register.

00:08.650 --> 00:10.660
So let's open our template.

00:12.980 --> 00:17.720
And then go down and hollow out this section.

00:29.040 --> 00:31.980
Now take a look at register -.

00:32.460 --> 00:36.540
If you want to empty this register, make it all zeros.

00:36.690 --> 00:39.360
We can use the XOR instruction.

00:40.290 --> 00:46.170
So just type "XOR -, -"

00:46.200 --> 00:48.960
and click "OK."

00:52.720 --> 00:57.310
Now when you run it, put a breakpoint first and then step over.

00:59.140 --> 01:03.370
Then when you step over this instruction, watch what happens to the register.

01:04.000 --> 01:05.140
It becomes zero.

01:06.040 --> 01:08.020
So let's try that for -.

01:08.470 --> 01:09.640
So over here,

01:11.710 --> 01:14.950
we "XOR -, -."

01:16.390 --> 01:27.880
OK, now we are going to step over this and see -. Step over. - also becomes zero.

01:28.990 --> 01:33.820
So you can use this simple way to zero out any register you want.

01:34.630 --> 01:36.310
Of course, you can also use MOV.

01:37.060 --> 01:46.270
For example, you could "MOV -," let's say, "0x0" to -.

01:48.400 --> 01:52.390
And then step over and watch

01:52.420 --> 01:53.170
-.

01:54.460 --> 01:57.550
- will become zero, but there is a difference.

01:57.730 --> 02:06.130
XOR uses only three bytes, but MOV uses 1, 2, 3, 4, 5 bytes.

02:06.130 --> 02:07.780
So XOR is shorter,

02:08.290 --> 02:09.610
a shorter instruction.

02:09.730 --> 02:14.800
So preferably we use XOR because it's only three bytes.

02:16.510 --> 02:18.610
So that's all for this lecture.

02:18.880 --> 02:20.170
Thank you for watching.