Assembly

Course
Time
13 hours 15 minutes
Difficulty
Beginner
CEU/CPE
14

Video Transcription

00:01
Hello. This is Dr Miller, and this is Episode 6.5 of Assembly.
00:06
Today we're gonna talk about a function prologue and then example code.
00:11
So the function prolong.
00:14
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.
00:25
And we've already seen examples of it.
00:27
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
00:42
arguments and parameters, the E BP Register gives us a constant way to reference those.
00:49
So this is the code that is the prologue.
00:52
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.
00:59
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
01:07
now e v p is pointing to its old version of itself. And then we have arguments that are a different levels from there.
01:15
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,
01:25
then inside of our function, we have our function Prologue. So pushy VP movie PSP.
01:33
So here we can just view the stack as we go through.
01:36
So when we execute this push beef beef, right, that's on top of the stack.
01:41
Now we're gonna push cafe onto the Stack Cafe Cafe.
01:45
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.
01:56
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.
02:04
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.
02:12
So now E b p points to this constant location.
02:15
And so from here, the BP plus four is our return address. Plus eight is Cafe Cafe and plus 12 is beef beef.
02:24
So again, this is going to give us a constant reference pointer.
02:30
So here is the full example.
02:34
So we have our enter and push A and r pa pay. And then we're all done
02:39
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.
02:52
So today we talked about the prologue and then I showed you the example code that we have for that.
02:58
Looking forward, we're going to talk about a function epilogue,
03:01
and then our quiz. What is the prologue consist of?
03:07
It consists of the code pushy BP movie V P E S p.
03:13
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

Up Next

Assembly

This course will provide background and information related to programming in assembly. Assembly is the lowest level programming language which is useful in reverse engineering and malware analysis.

Instructed By

Instructor Profile Image
Matthew Miller
Assistant Professor at the University of Nebraska at Kearney
Instructor