So guys in the studio, we are going to see another important topic called Stack and Stuckey's refolded
are structure stands, transfer to foster data structure.
It means that when you're in certain elements into the stack and it will be the last element you need
to take back from the stack.
The example for the stack is stack of books.
So in this example, let's you have a table and you have 10 books and you will place the books one one
by one on the top of each other.
So you'll play the first book on top of the first book.
You play the second book.
And on the top of the second book, you play the third book and so on, on top of the ninth president.
And so in order to take the books, you need to first take the to write.
You cannot take from sideways.
You only need to take from the top.
So that means you need to take the first and the book and then the ninth book and then eight and so
on a per second book.
And finally the last book will be the first book.
So this behavior is called Ashton Foster.
That's very striking correlation, foster data structure.
And also we can only perform two operations on the stack.
Those operations are called push and pop operations.
Push operation can be construed as placing the book on the table and pop operation can be considered
as taking the book from the stack of books.
So pushing means pushing an element to the stack and taking the top of the element furniture.
So this Abipon and E.S.P are registers are not covering in the resistance will go.
No, I'm going to cover this.
EVP is called Base Pointer and EVP points to the base of this time frame.
It means that EVP points to the starting of the political spectrum and E.S.P, which is the stack pointer
points to the top of the spectrum.
So if you keep on pushing the elements out of the stack, then E.S.P will point to the top of the top
element of the stack frame.
So if you if this sounds confusing, don't worry.
I will I will be showing some diagrams now.
Now, let's consider these two instructions.
Firstly, the push SBP.
So actually this is called the function prodrug.
It means that whenever there is a new function in any other language like C, then a new style frame
is created for that particular function.
And whenever that function has been written or exited, then this time frame gets collapse.
So this is the function product and this creates a new structure.
And this does by pushing that SBP, which is the previous function stack frame, and this value gets
pushed out of the stack.
Now you can see Push EVP has been executed and the theory will be this points to the this function stack
from previous functions and more will become ISP.
So we are moving the E.S.P value to the IP so that these Google points to the base of the stack.
That is the beginning of the stack.
So these two instructions need to coordinate assembly, but because we will be coding and programming
that start function.
So I wetering this concept.
So our START premise created no E.S.P.
EBP both points to the starting of the stack.
There are no elements.
And from this address, four two three one four eight four, our stack begins.
This is the third SBP address.
Not what I'm going to do is I'm going to push an element.
Let's say I want to push the value.
So this file will be placed on the top of the stack and E.S.P points to this top are the top element,
which is fine, as you can see us now.
Not disastrous for it.
Two three one four eight eight and disorder's eight four eight eight eight four.
So the stack grows from I remember I remember that.
I still remember memory address.
And whenever you push an element out of the stack, you can see the E.S.P decrements by four by four
bytes, because in that little bit we generally push the 32 bit value so that it means the forward so
normal push operation.
Operation Decrements, the.
E.S.P by four points, and if I want to push another element, let's push Dirac's seven, then that
value will be pushed onto the start again E.S.P decrements before and points to the top of the stack,
which is seven.
OK, now what if I want to take another step so we cannot fail because we need to take her to tell.
So the population automatically pops the I mean takes the top element and push prices in the to register.
So now I want to say popi x so the top of it is seven and it's been placed into the X, the old memory
or that off the X has been ordered at seven.
Now as you can see before in the previous E.S.P points to this address.
So whenever a pop operation has been executed, then E.S.P incremented by four.
That means E.S.P no longer points to this seven because 05 is the top of the stack and E.S.P increments
before when a popular pop operation has been performed.
So what if I want to do the pop operation again?
And now this.
I want to say Popke X and the top of the stack before this pop is five and this fight will be copied
in books.
And then before E.S.P has been pointed to this eight four address and now after the Operation E.S.P
point is pointing to the Aetate address, it means that Pusha Operation Decrements, the USP by four
bytes and pop operation determines the value we increase the value for which.
So as you can see, guys, when you are referring to the memory, actually you are the difference in
these two memories addresses.
So if you have taken my C programming course and you can see I have explained you in the studio and
these two Artosis will be there on the stack and these values will also be on the stack.
We are just not referencing this to memory Artosis and the.
So Noguez will be moving on to the podium and let's do an example.
That's no, I'm going to create a new car tag, but now some.
Now, I'm going to write the global underscores.
Now, I want to define a variable in the data section that I'm going to write the data section.
Now, that's the variable, that one.
Let's say over.
Are we going to the world and we just put the of value onto the stock?
So this word will point to that word and will be pushing this value onto the stack.
Now let's create the U.S. to hold our core.
And we need to define the start.
OK, guys now will be moving some random values.
Let's let's copy Google into the eggs and then let's push your eggs one zero three Litsa and we also
push 066.
But seven, now, these two values will be pushed onto the stack, now we can say bump into X.
And this instruction will take the direct where you direct certain value and it in here, because it's
the recent push and recent pop will take the risk and push value.
I'm going to say pop Ebix.
Now, this instruction will be the second pop operation from the last on what's the second push?
I mean, Trevallyn will be presumably because know there is one more matter I want to show you.
We can push particular bites of it, which I want to push forward.
And said Brackett.
Wear one.
So what this what this means, push the content at one, but push only the word, I mean, push only
the two bits of the content, look at it by the point or whatever one address knowledge of this.
Let's talk about this in two weeks and also we will see.
Bush Beever.
There was the what is the four bites and we are going to push the four bites available one, and we
will again pop this into evicts now we need to exit the program.
To do that.
We need to cover the right exit system called.
Now pressing the one that is the number in two years and the exit of Girot, so we need to place the
in and we need to call the interprete.
So let me see the file.
And we are going to compare it using that nasal.
Now we will object to using Aldy.
Now, our tag boundary has been created now later on this.
So since we are not printing anything, the program just existed normally.
Now let's open this binary in the bigger GDP, the bigger.
Now, let's say in four functions.
And I'm putting the breakpoint at the start function.
Now, let me run the program now, as you can see, the next U.S. is going to be the movie zero two.
So now let's run that introduction next time.
So X condensed two and push three.
So this is our guys.
Now, there is already one and the address.
So as you can see, this is the stack growing from here.
That means if you place the element, it will be here.
Now, let's run the step through the code.
As you can see, three has been executed and the top of the stack contains three previous reads, one
now it's three.
As you can see, the address also has been created by four.
As you can see now, the default Bush operation, sorry, push, Operation Default, KRI Decrements,
yes, people thought it means that it takes the value and by default, it places the 32 bit where,
you know, if I step through this again, you can see the direction.
Now we are going to pop you now yak's contents to allow you to hand the top of the stack.
So this initial action on execution, but this is the seven into the years.
So no eggs content, seven in a similar manner directly is the top of the stack.
And if you pop into buycks now, you can zero.
It will be replaced by three.
As you can see, Buycks contains three.
Now we need to look something somewhat carefully.
Push already.
Well, in the previous pusher's, it default taken the B word that we do with and pushed down the stack.
Now let's run this one.
But only one operation.
Now, as you can see now, let's take this to check the contents of this address.
So the contents of this are 2046, OK?
These should be placed onto the stack.
I don't know why there is one.
OK, now let's step through this.
Now we are going to.
Now we are going to push that the whole operation that we started to bits, actually, we have the 123456
on it and that will be pushed under the stack.
As you can see, there is Durex, 123456 on it.
Now, if I pop into SBX this value and put it on, it will be comparable to this value this.
Now, as you can see, it contains 123456 on it.
Now, these last instructions tell us that we are calling that exercise stronger now, if I simply run
this our program at just normal, guess one main thing you need to understand is the other portion of
operations and the Bush operation decriminalizes people for bits and pop operation increments that.
Yes.
Wait for.