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 1.5 some of assembly.
00:06
Today we're gonna talk about the template and how it works.
00:09
So the assembly template that I have developed
00:13
So what this does is it creates a new directory for each project that you're working on,
00:17
and then it creates a make file for your project. And this is using the standard tool called make, which allows you to build your project.
00:25
So when you download the make template dot r dot gz and you unzip it
00:31
inside of there, you'll find a directory called Template make and inside of it or a bunch of different files
00:37
that are used for our process.
00:41
And so we're gonna look at some of those files so you can kind of understand what's going on.
00:46
So first is fixed. That s H. So this is the program that allows you to automatically add this to your path.
00:55
And so the way it does it is it creates a BIN directory for you, and then a copies the gen make dot s H file into that bin directory.
01:03
And then what it does is it adds on to the path. So the path is how your shell knows how to find
01:08
where commands are. And so it adds on to the path by a pending to the dot bashar see file.
01:15
And this allows it so that your your
01:19
shell will be able to see the program Bashar see is what it reads by default with bash views the different shell. You'd have to modify that in order for it to work.
01:27
And then it creates a folder called Projects. And this is where all of your projects are gonna go
01:33
now inside the make file,
01:34
we got a couple of different things. If you've never seen a make file, we can kind of start at the end. So clean just removes files,
01:41
and here you're going to see *** all over the place. That is the name of your project. So that's actually gonna get replaced with the name of your project so clean will just delete that.
01:51
And then all says we're going to make Project ***. So if you take make it automatically looks for a file called make file in a gnomic looks for
01:59
a target called all
02:00
and so it's gonna try and build this? Well, *** requires *** 0.0, and s m I Oda. Oh, so *** 00.0 is generated with this one which requires our A s M file
02:12
and then sm I oda Oh, depends on this sm ioo dot sm file.
02:17
And so to build these, it's the command that comes directly after it.
02:23
And so here we have
02:23
a Nazem minus f elf Manistee elf type, and then it's gonna build this
02:29
so it's got an absolute path to that and then it builds the 0.0, file for you.
02:35
I'm gonna put that in your in your current directory
02:38
and then for our project. Our project is going to be called Whatever *** dot S m it's gonna build that file and it's going again. Use Nazem to compile it for us and then if those air successful than it used GCC to compile the driver and then
02:54
*** 0.0 or whatever anymore, Project is in a semi Oda. Oh,
03:00
and so it uses those that's the
03:01
in here and so go ahead and compile it for us using GCC. So that way, all of the GCC libraries are included in our project and so
03:14
that allows us to build the project and make is just inefficient tool to do that. So instead of having to type all these commands in individually,
03:23
you can just use make in order to build it for your project.
03:28
And then what's in a sm ioo dot sm these air a bunch of different functions that we're gonna use either an hour in the future. So, for example, read into print and print string read char
03:39
um, dump rags, print NL print car.
03:43
So all of those are gonna be defined inside of here. So here's an example. Read int is to find in here, and you can actually see the definition in assembly
03:51
of what Regent is and does. And so, if you want, you can peruse that.
03:57
And then the part that we always use is going to be gen make that s age. So what it does is the first argument is dollar sign one.
04:03
And so it's going to create. Here is the directory. It's gonna be dollar sign home, which is your home directory slash projects because we created that directory and then whatever your project name is,
04:13
and then if it doesn't exist If it does exist, it'll print out. Director exists, not created if it doesn't exist,
04:19
and I go ahead and create that directory, and then it copies the template dot sm into their, but it renames at whatever name your project is, so I'm gonna use example 5.1.
04:30
So if it's 5.1 has all the sign one. Then it's going to create the directory 5.1 and copy this file to create 5.1 dot sm in the directory under there.
04:43
Then it also copies this include file, which is required for that make file to build it,
04:48
and then it's gonna copy are make file. But what it's going to do is it's it's gonna take the text of our make file. And then you said to replace everywhere inside of our file that has ***. It's going to replace it with dollar sign one or 5.1,
05:02
and then that's going to get sent out to your make file
05:05
so we can see an example of the hat. Hold on.
05:11
Oh, here's our template. We'll see the example in a little bit. So this is a template that's in the, um make template directory. And so this is what it starts off with when you start programming.
05:23
If you don't like this, you can modify it. You can delete lines, you can add lines. But this is what will be used every project in the future when you create a project.
05:32
And then here's the example. So he did 5.1 so we can see inside of the make file. It replaced everywhere that we had *** previously. We now have 5.1 and so we have a file called 5.1 day sm 5.1 day. Oh, and so it's going to compile 5.1 That s m
05:49
into an object file called 5.1
05:53
0.0, using Nazem minus f f is the file type. We're going to use elf in this example.
06:00
So elf is the type of file format that Lennox uses for binaries,
06:04
and you will create that and then our GCC command will actually use that Oh file when it's building it. So it's gonna the driver actually looks for a function called Ask them underscore mean
06:16
and then it will include all of the libraries will get included in there also.
06:25
So today we looked at the template and kind of how some of the parts of it works, so that if you want to go on your own and do this, you can go do that and you don't have to rely on the template.
06:35
But the reason that we have the template is that helps to make it so that it's easy to create a new project. So you can start coding in that without having to do all of the set up and all the copying. And also it organizes our stuff into projects and directories. And so it's a lot easier for us to,
06:50
um, write code. That way,
06:54
if you have questions, you can email me Miller MJ at you and Kate I e. To you. 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