Hello. This is Dr Miller, and this is Episode 6.5 of Assembly.
Today we're gonna talk about a function prologue and then example code.
So the function prolong.
So the function prologue is what we do when we enter a function. It's a set up to create the function so that people can program in it. And most compilers will do this automatically.
And we've already seen examples of it.
And so one of the things that it does it saves the E v p Register because it's going to use that as our base pointer. So the E V P register or extended based pointer gives you a constant point of reference. And so when we in the future get to talking about
arguments and parameters, the E BP Register gives us a constant way to reference those.
So this is the code that is the prologue.
So first we're going to save onto the stack the old version of E. BP. So pushy BP. Now that's on top of the stack.
And then we set the base pointer to the E S P pointer or extended stack pointer. So it's a movie. B P E s p
now e v p is pointing to its old version of itself. And then we have arguments that are a different levels from there.
So here's an example. So you have the top of our stack. We've got a couple pushes here. We've got a call of a function. We fix the stack when we're done,
then inside of our function, we have our function Prologue. So pushy VP movie PSP.
So here we can just view the stack as we go through.
So when we execute this push beef beef, right, that's on top of the stack.
Now we're gonna push cafe onto the Stack Cafe Cafe.
Now we're going to call the function. Remember, when we call the function, the return address is going to get pushed on top of the stack and then we'll enter that function as the next instruction will execute.
So on top of our stack is our return address, and then we have down here cafe cafe, and then beef beef red so they keep getting pushed down.
So now we're going to save E v p. So our old e v P is now stored on the stack, and now we set E b p T e S p.
So now E b p points to this constant location.
And so from here, the BP plus four is our return address. Plus eight is Cafe Cafe and plus 12 is beef beef.
So again, this is going to give us a constant reference pointer.
So here is the full example.
So we have our enter and push A and r pa pay. And then we're all done
And then we have our pushes here are called our function. We correct the stack and then inside of our function, we have the prologue. And next time we'll talk about the epilogue.
So today we talked about the prologue and then I showed you the example code that we have for that.
Looking forward, we're going to talk about a function epilogue,
and then our quiz. What is the prologue consist of?
It consists of the code pushy BP movie V P E S p.
If you have questions, you can email me and Miller M. J a U and Keita et you and you can find me on Twitter at Milhouse 30