WEBVTT

1
00:00.770 --> 00:02.150
Hello and welcome back.

2
00:02.150 --> 00:06.110
In this lesson, we are going to learn how to use the ADD instruction.

3
00:06.710 --> 00:10.340
So let's open our template.

4
00:12.670 --> 00:15.520
And zero out this part again.

5
00:23.460 --> 00:26.700
So how does the ADD instruction work?

6
00:26.730 --> 00:28.230
Let me give you an example.

7
00:28.920 --> 00:31.500
Supposing we have - here.

8
00:31.980 --> 00:38.910
Before we use -, we need to zero it out, so we "XOR -, -."

9
00:39.510 --> 00:40.290
-.

10
00:44.590 --> 00:46.480
Now we are going to zero.

11
00:46.870 --> 00:51.730
We put a breakpoint there and run, step over and step over.

12
00:51.730 --> 00:53.020
And now - is zero.

13
00:53.680 --> 00:56.320
Next, we are going to add one to -.

14
00:56.920 --> 01:01.450
So to add one to -, we just type "ADD

15
01:05.060 --> 01:06.170
-"

16
01:06.290 --> 01:07.850
and one.

17
01:11.210 --> 01:12.560
This is to add one to -.

18
01:12.650 --> 01:14.150
So we step over and we see—

19
01:14.150 --> 01:15.620
now got one.

20
01:21.040 --> 01:21.520
All right.

21
01:21.520 --> 01:26.620
So now if we wanted to add—let's try another one.

22
01:27.570 --> 01:28.320
ADD.

23
01:31.550 --> 01:32.450
Add something to it.

24
01:32.750 --> 01:34.400
Let's say you add a very big number:

25
01:35.450 --> 01:40.040
1122334455667788.

26
01:40.730 --> 01:43.970
You will see immediately that there is an error here.

27
01:44.810 --> 01:45.560
Why?

28
01:45.770 --> 01:53.930
Because there is a limitation when you want to use the immediate value to add to a register.

29
01:54.200 --> 01:59.360
The limitation is that you can only do it with four bytes.

30
01:59.510 --> 02:03.440
That means now you reduce it to four bytes,

31
02:03.440 --> 02:05.390
and now this instruction is OK.

32
02:05.600 --> 02:08.510
That's the limitation, you see.

33
02:08.510 --> 02:11.510
So how do you overcome that limitation?

34
02:12.080 --> 02:16.550
To overcome the limitation, you move the big number to another register.

35
02:16.550 --> 02:19.670
Then you add the register to -.

36
02:20.990 --> 02:21.770
Let me show you.

37
02:23.650 --> 02:34.540
First, we move the big number to - or any other register: 1122334455667788.

38
02:37.720 --> 02:39.400
Then we ADD

39
02:41.110 --> 02:41.830
-, -.

40
02:42.190 --> 02:42.910
-.

41
02:46.980 --> 02:50.700
But before that, let's zero out -.

42
02:53.030 --> 02:56.030
So that we can see the result.

43
02:57.680 --> 02:58.820
Then we ADD

44
03:00.800 --> 03:01.580
-, -.

45
03:01.610 --> 03:02.300
-.

46
03:04.810 --> 03:06.430
So now we are here.

47
03:06.970 --> 03:08.230
Let's step over.

48
03:11.570 --> 03:14.720
So we move this big number to - first.

49
03:15.200 --> 03:16.850
Then we zero -.

50
03:16.850 --> 03:18.290
So - is zero.

51
03:18.500 --> 03:21.800
Then we add - to -, step over.

52
03:21.800 --> 03:25.220
And now you see - can take the big number.

53
03:25.610 --> 03:31.640
So these are the limitation for adding immediate values: when you add an immediate value to a register,

54
03:31.820 --> 03:34.190
there is a limit of four bytes.

55
03:34.280 --> 03:39.950
If you want to bypass the limit, you have to do it this way.

56
03:40.190 --> 03:47.090
You move the value to a register first, and then you

57
03:47.120 --> 03:49.250
add that register to -.

58
03:49.280 --> 03:51.830
Then you can have eight bytes.

59
03:51.830 --> 03:53.240
You can add eight bytes.

60
03:53.600 --> 03:55.790
So that's all for this lecture.

61
03:55.790 --> 03:57.020
Thank you for watching.