### Assembly

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

### Video Transcription

00:03
Hello. This is Dr Miller and this is Episode 7.4 of Assembly
00:08
today. What we're gonna do is we're gonna take a program that we've already Britain and we're going to convert it so that it uses Mac Rose.
00:16
So for this program, it's the some program that we did earlier.
00:19
And when we did it, we used hard coded offsets. And so we'd like to do is convert those offsets to either parameters or arguments, depending on which one that they are.
00:42
Alright, So I've logged onto the server, and now what I'm gonna do is I've already got the code set up.
00:51
00:58
01:02
And so what we're gonna do is we're going to come down here, and we're just going to convert this program so that it uses the appropriate Mac Rose.
01:10
So what we're gonna be replacing
01:11
is this here?
01:19
So the first thing that we have to do is we have to say, push some sort of context, and it's just the names of the
01:25
The assembler knows what we're doing, and then we can set our stack size,
01:34
and then we can create a special variable that the assembler will use to figure out how many local variables we have.
01:47
And we're just initializing it. And then basically, we can tell it what arguments we have. And then what? Local variables have so percent? Argh!
01:57
So n is the number that we used in our C program and then for our locals.
02:13
So I'm defining each one of these is the D word, which means of the take of four bites.
02:29
And then this should allocate the local size that it defined when it was looking for each local variable.
02:38
And so, in this case, it should be eight. Right? So we have to de words. And so it should end of generating the number eight for that.
02:45
And then we'll go down here to the bottom, and then we just got oh, pop that context.
02:52
So that will remove that context so that the assembler will work right. And then down here, instead of the epilogue, we're going to use leave,
03:00
which does the same thing,
03:02
so should fix our stack appropriately.
03:06
Now, when we come into our program, we need to find every place that we used a hard coded offset CBP minus four.
03:13
And we can just use the variable that we've defined. So this should be some.
03:19
This one is I. So I is minus eight, so I'll go ahead and find all the place I
03:29
each one of these will become, I and then minus four is some.
03:44
And then we see you had E b P plus eight, which is n and so we can just use. And in this case,
03:52
So when you start your program from scratch or to be a lot easier to start with this because then you can just use variable names instead of trying to remember the hard coded offsets.
04:01
So we should be able to build this
04:08
all right?
04:12
And we should get thesafeside results that we got before.
04:19
So we today we talked about converting our program so that it didn't use hard coded offsets, which are much more difficult,
04:27
but we saw that we had a little bit more work to do up front, and we learned what that work is. And then how we could do that. In an example,
04:36
Looking forward, we're going to start talking about floating point numbers and how we do operations on floating point numbers within a computer.
04:45
If you have questions, you can contact me at Miller MJ at you and Kate. I e to you. And you can find me on Twitter at Milhouse 30.

### 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

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