Hello and welcome back.
In this lesson, we are going to learn how to use the ADD instruction.
So let's open our template.
And zero out this part again.
So how does the ADD instruction work?
Let me give you an example.
Supposing we have - here.
Before we use -, we need to zero it out, so we "XOR -, -."
-.
Now we are going to zero.
We put a breakpoint there and run, step over and step over.
And now - is zero.
Next, we are going to add one to -.
So to add one to -, we just type "ADD
-"
and one.
This is to add one to -.
So we step over and we see—
now got one.
All right.
So now if we wanted to add—let's try another one.
ADD.
Add something to it.
Let's say you add a very big number:
1122334455667788.
You will see immediately that there is an error here.
Why?
Because there is a limitation when you want to use the immediate value to add to a register.
The limitation is that you can only do it with four bytes.
That means now you reduce it to four bytes,
and now this instruction is OK.
That's the limitation, you see.
So how do you overcome that limitation?
To overcome the limitation, you move the big number to another register.
Then you add the register to -.
Let me show you.
First, we move the big number to - or any other register: 1122334455667788.
Then we ADD
-, -.
-.
But before that, let's zero out -.
So that we can see the result.
Then we ADD
-, -.
-.
So now we are here.
Let's step over.
So we move this big number to - first.
Then we zero -.
So - is zero.
Then we add - to -, step over.
And now you see - can take the big number.
So these are the limitation for adding immediate values: when you add an immediate value to a register,
there is a limit of four bytes.
If you want to bypass the limit, you have to do it this way.
You move the value to a register first, and then you
add that register to -.
Then you can have eight bytes.
You can add eight bytes.
So that's all for this lecture.
Thank you for watching.