Hello, and this is Dr. Miller, and
this is Episode one point five
percent of assembly
today we're going to talk about the
template and how it works.
So the assembly template that I
have developed.
So what this does is it creates a
new directory for each project that
you're working on and then it
creates a makefile for your project.
And this is using the standard tool
called MAKE, which allows you to
build your project.
So when you download the
make template together
and you unzip it inside
of there, you'll find a directory
called a template.
Make an inside of it are a bunch
of different files that
are used for
our process.
And so we're going to look at some
of those files so you can kind of
understand what's going on.
So first is fixed that S.H.
So this is the program that allows
you to automatically
add this to your path.
And so the way it does it is it
creates a binder victory for you
and then it copies of the gene make
S.H. file into that bin
directory.
And then what it does is it adds
onto the path. So the path is how
your shell knows how to find
where commands are.
And so it adds onto the path
by appending to the Bashar C
file.
And this allows it so that your your
shell will be able to see the
program. Bashar see is what it reads
by default with Basche.
If you use a different shell, you'd
have to modify that in order for it
to work.
And then it creates a folder called
Projects. And this is where all of
your projects are going to go
inside the Makefile.
We've got a couple of different
things. If you've never seen a
makefile, we can kind of start at
the end. So clean just removes
files and here you're going to see
all over the place that is the name
of your project. So that's actually
going to get replaced with the name
of your project.
So Clean will just delete that
and then all says we're going to
make Project X, so if you type make
it automatically looks for a file
called Makefile and anomic looks
for a target called
all.
And so it's going to try and build
this well, x, x requires
ZoGo and ASRM
Io so
O is generated with this one,
which requires RSM file
and then ASRM
O depends on this Asmir
ASRM file.
And so to build these, it's the
command that comes directly after
it.
And so here we have
Nazan minus F, F minus
Delph type and then it's going to
build this.
So it's got an absolute path to that
and then it builds the
file for you.
I'm going to put that in your, in
your current directory and then for
our project, our project
is going to be called whatever
m it's going to build that file
and it's going to again use Nazeem
to compile it for us.
And then if those are successful
than it used to compile
the driver and then
O or whatever anymore project is
an assembly O
and so it uses those that's the
in here.
And so it'll go ahead and
compile it for us using
Jook. So that way all of the
libraries are included
in our project and so
that allows us to
build the project and make is just
an efficient tool to do that.
So instead of having to type all
these commands in individually,
you can just use make in order to
build it for your project.
And then what's in HSM Io
ASRM? Well, these are a bunch of
different functions that we're going
to use either now or in the future.
So for example, read in print
and print string read char
dump Braggs print and print
car.
So all of those are going to be
defined inside of here.
So here's an example read.
It is defined in here and you can
actually see the definition in
assembly of what reading
is and does.
And so if you want, you can peruse
that.
And then the part that we always use
is going to be, Jen, make that S.H.
So what it does is the first
argument is dollar sign one.
And so it's going to create here is
the directory. It's going to be
Dollar Sign Home, which is your home
directory slash projects, because
we created that directory and then
whatever your project name is.
And then if it doesn't exist,
if it does exist, it'll print out
directory exists, not created.
If it doesn't exist, then
I'll go ahead and create that
directory and then it copies
the template DSM into there,
but it renames it whatever name your
project is.
So I'm going to use the example 5.1.
So if it's five point one
as all design one, then it's going
to create the directory 5.1 and
copy this file to
create 5.1 ASRM
in the directory under
there.
Then it also copies this include
file, which is required for
that makefile to build it,
and then it's going to copy our make
file.
But what it's going to do is it's
going to take the text of our
makefile. And then you said to
replace everywhere inside
of our file that has X X,
it's going to replace it with Dollis
on one or 5.1
and then that's going to get sent
out to your make file.
And so we can see an example of
that. Hold on.
Oh, here's our our template
and we'll see the example in a
little bit. So this is a template
that's in the make
template directory.
And so this is what it starts off
with when you start programing.
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.
And then here's the example.
So we did five point one so we can
see inside of the make file, it
replaced everywhere that we had
previously.
We now have five point one.
And so we have a file called
five point one Dadaism five
point 1.0.
And so it's going to compile 5.1
RASM into an object
file called five point one
using Nazeem minus F F
is the file type one.
We're going to use ELF in this
example.
So ELF is the type of
file format that Linux uses for
binaries.
And it will create that and then our
command will actually use that
file when it's building it, so
it's going to the driver actually
looks for a function called
HSM underscore main,
and then it will include all of the
libraries will get included in there
also.
So today we looked at the template
and kind of how some of the parts of
it work 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.
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 setup and all the
copying.
And also it organizes our stuff
into projects and directories.
And so it's a lot easier for us to
write code that way.
If you have questions, you can email
me Miller MJM you in Canada, Eddo
you can find me on Twitter at now
has 30.