Hello, my name is Typhoon and in this lecture we are going to write our Makefile to compile this program.
Also we will get again as we did in the previous lecture, we will get the move that or output move
that lStm and move that um M as well.
And I will also produce the move executable move file.
Um, well, so here what we're going to do is we will first go to, um.
Assembly here.
We have the Move project here.
Um, as you can see.
Oops, move, uh, clear here.
So we have moved that here.
What we're going to do is we will open our some text editors in this case.
We also cannot convert gedit or mousepad.
Yes, it depends on is here and we will create something named make file and that's it here.
So what we're going to do is we will need to, uh, right, right here with move, start writing with
move here.
We will first create a move that all this line defines a rule in the make file.
It states that the target move depends on the file move.org.
So this means that if move that all is modified or doesn't exist.
Um, then the target moves rebuilt using this comment here.
And also, uh, we will.
At GCC or move.
But also we will use the no pi here, which I will explain right now.
So this this command is used to link the object file, move that or into the executable named move here.
So it uses the GCC compiler and this all here specifies the output file name.
And this no Pi is a linker option that disables position independent executable in this case pi generation.
So Pi is a security feature that randomizes the address space of the executable, but it's being disabled
here because we want to debug it.
So here we will also add the move.org here.
Now we will move that ESM.
So this line defines the another rule in the make file.
It indicates that the target moved at all depends on the file moved at RSM.
So if we move that RSM is modified or doesn't exist, the target moved at all needs to be rebuilt using
this command here.
Nasm f elf 64 g Move that SM or move that all here and move that LST.
So this command assembles the assembly file, move that RSM using the Nasm here Elf 64.
Now let's break the down options and arguments here.
So f Elf 64 specifies the output format to be Elf 64.
The G here generates a debugging information which can be useful for debugging with tools like GDB or
here.
And this move that RSM this is a source assembly file to be assembled and not this all move that all
here specifies the output file name as moveto and L here.
This is the generates a listing file containing the assembly code along with the memory addresses so
the this listing can be helpful for reviewing reviewing the assembly code as well.
So to summarize the provide a set of commands and rules as are part of the make file which is used Automate
the build process for an assembler program.
So the make file defines how the executable move is built from the assembly source file and move that
RSM by by assembling it into an object file, move that over here and then linking it to g C.
So now what we're going to do is we will save this file right now here and we will continue.
On drawing or on starting out and debugging or JC here.
So now, uh, here.
Clear.
So, cat make file and as you can see, make file is written here and here.
Now we will just press write make, and that's it.
Our program is compiled.
And as you can see, we have this executable file here.
So if we run this and as you can see, we have no output because we are working in a memory.
So now, uh, we saved, uh, the source file.
Yes, everything is okay.
And here we will need to start a triple D, so I will call it D.
The DVD here.
Move.
And that's it.
We installed DDT in actual dribbled is more easy to pronounce.
So I use I.
We installed a triple D in previous lectures, so we will not install it again.
And here we have some informations on blah blah blah here and that's it.
So here you will see this graphical user interface with a rather dated layout.
And DDT is an old open source tool and apparently nobody is willing to adapt it to the graphical user
interface standards we are used today.
And so you have a window with your source file, source code displayed and window where you can type
gdb, gdb command.
So there is also a floating panel where you can click run here.
And see, here we are.
This is the terminal.
We can type GDB commands and if we click on the service menu and um, let's actually click on the source,
uh, menu and.
Um.
Here.
Uh, as you can see here, uh, menu.
And we can, uh, display.
Display.
Uh, line numbers.
Here for.
As you can see here, we have find find words only find case sensitive only line numbers, display machine
code in the source and so on.
So we will click on display line numbers.
Um, we can see the line numbers on the left like the most the new text editors and in the same menu
can choose have a window with the assembled code as well.
So now, uh, we will place the cursor here on this, uh, main and we will right click here.
And here, as you can see here, we will actually let's actually place run here.
And here we can in right click on it.
Now, uh, here.
We can also set the breakpoint here.
Also we now we if we run this again and this, you can see we're one breakpoint main at that in 15 line.
And.
Here.
Uh, let's actually right click on the again.
And as you can see, we have also commands program.
Cool here.
Edit on.
And here again, delete this breakpoint.
Sable.
You can also delete and disable the breakpoints.
But here in this case, let's actually delete again and I will.
Let's run it again.
So what we're going to see is and what we are need to see is we will need to see registers, which this
is the whole logic of this code.
That's why we written this code to show something on registers, uh, which now we will add the main,
uh, main the breakpoint at the main here.
And to observe and understand how the content of registers changes with the this move command, we will
follow.
We need to place the cursor in the front of the main here and we right click on it.
And now we will choose a break.
Or you can also click the.
Yes, uh, you can also click break here on.
It's on break.
And.
Or you can also click on the top of this menu, uh, on the, uh, stop icon here, as you can see here.
But it's right.
Just right click on it and choose break.
And then we will click on Run here on the floating panel debugging.
So this will start a debugging process.
And now we will click on the status here in the top menu bar and then select registers.
So this action will open a window displaying the current values of registers here.
Here.
Make it a little.
But will.
To our screens.
Oh, this is so wide here.
Don't need.
This debugger needs to be updated at.
Graphical here.
But this.
And that's it here.
So.
And after that we will click on this step here to execute the current instruction in the program.
This.
And see here.
Up in.
And here.
As you click this step, you will observe.
You will able to observe how the values in registers change with each step through the program.
If you wish to inspect memory addresses like you num1 or be num, uh, you can uh, go to the view option
here.
And to make the data window visible here and under this data.
But now it's.
I'll.
Was this.
No, we don't want to close this.
I don't want to do it again from zero here.
Let's actually make it.
Down here.
And here, um.
Under here and go from here.
Step.
Here.
Up and up.
Finish.
Interrupt.
That's it.
Now we will run it again.
And here.
You.
Data window.
Even though.
And here, as you can see here, we are seeing our variables as well.
But the most important thing here is in registers.
So and keep in mind that.
Here.
Keep in mind that the while DVD has a graphical interface, it can sometimes be intricate to navigate.
So if you find it faster you can use gdb which is uh, this.
GDB is better, which is and gdb input window for better for certain tasks.
And it's important to keep in mind that DVD is built up on top of gdb.
The new debugger and consequently using a proper function, prologue and epilogue code is essential
to avoid potential uses during the program execution and typically ignores the function prologue while
stepping with the code here.
And the primary objective of this code is to demonstrate how the move command actually again I want
to do it again here how this move command.
Here impacts the contents of registers.
Right.
As you can see, in racks.
You're always changing the here.
Now see here.
Now it's one, two, three, four, five, six.
An.
It's done because there's a.
Its program is at the read here.
So interrupt it, run it again.
And as you can see, Rex is something just random thing here.
But and in this here we are filling Rex with once.
And here we are.
Step.
Here.
And as you can see here, here now, Rex has the correct value here, which is zero for now.
And here we are filling Rex with ones.
And as you can see, here is the Rex value is one, two, three step again minus one as it did here.
Then again, minus five, 319, one step again and zero again.
So now let's step again and one, two, three, four, five, six, which is the value of our.
Welcome here.
One, two.
We?
Yes.
Again, minus one.
And here we also.
Again.
And no one here.
And after that.
Lastly, we are seeing this move Racks Keenum 123456 here.
And here we are, instruction for floating point number.
And that's it.
So this is, um, how have you, as you continue stepping through the code, you will notice that when
you move a 32 bit value into a 64 bit, register the higher bits in the 64 bit registers are cleared.
So likewise, when you move value in to ax the upper bits of Rax are cleared.
Well, so this insight is vital to keep in mind during programming and debugging.