Hello, my name is Steve.
Welcome to this lecture.
And in this lecture we are going to compile this program, create a mac file for it.
And also I will explain this code line by line first.
First of all, let's actually make our code look nicer here.
Let's add a enter here, the new line.
Have a new line.
And also.
New line here.
So the code is going to be read for us.
And that's it.
So now here, let's get started by explaining this code by line by line.
And what we're going to do is firstly, I will explain this data section, which are which we are defining
the various data variables with different sizes.
So actually we also need the grommet.
Let's actually mark it down to.
Now we are I'm explaining this data here.
So in the first year in Vietnam, we are defining a bite size.
In this case, eight bits for this exploit.
Okay, So this is eight bits.
Um, variable with the value of one, two, three.
And in w num.
Here we are defining a word size in this case, 16 bits.
Um, 16 bits variable with the value of one, two, three, four, five.
And in the Num we are defining a double word size.
In this case it is 32 bits, a variable with a value of 1234567890.
And in num one we are defining a quad word size variable with the value of this here.
In this case, this variable size is 64 bits here, 64 bits.
In this case it's 32 bits, 16 bits and eight bits.
And also in num one, yes, we are defining the 64 bits we already explained.
And in M2 we are defining another quad word size variable with the value of one, two, three, four,
five, six.
In this case, this is also 64 bit and also this is also 64 bit because we defined that as a quad word
size variable.
So and in N3 we are again defining a codeword size variable with the value of 3.14.
It is also 64 bits here.
And here in the section, the section will normally contain initialized data, uninitialized data.
But it seems like there's a we didn't add.
No variables are defined in the section because we don't have any unusual uninitialized data here and
here in this section.
We as you can see, yes, in the section text here, this is the section is for code instruction.
This global main directive specifies that the symbol main is globally accessible entry point for the
program.
And also we have this main push rb r, BP and RWP rsp.
This is this main label marks the start of the main function.
So this code sets up a basic function prologue by saving saving the current value of the base pointer
r bp onto the stack and then copying the current stack pointer rsp into our BP here.
So and after that, we have four lines of code defined here.
So this is for the these are the instructions, um, manip to manipulate the rax register.
This is a general purpose 64 bit register.
So rax is 64 bit.
But you can also open this cheat sheet cheat sheet for the 64 bit registers here.
So 64 bit registers.
So here, as I added comments here, the move rax minus one fills the entire rax register with ones.
This move a l bite b num loads the value of b num.
In this case b is 123 into the lower eight bits of rax preserving the upper bits.
And also we have the XOR rax rax.
This clears all bits, all bits in rax and move a l bite b num.
Again, we are using one, two, three calls, we are using B now which holds the value of 123.
This loads the value of b num into the lower eight bits of rax now correctly here, so similar instructions
are used for this.
Here.
A similar instructions are used for here, a x and a word here, a keyword and a x, which is, as you
can see, for Vina.
And so we are again manipulating this rax register here.
So move rax minus one again fills the rax with once more rax keyword w num.
Loads the value of uh, the PR uh.
W I'm here again.
But this is the almost the same with this one here in the previous one.
But what's interesting here is this.
So again, we are at the start.
We are all the same.
So we are moving the racks, move racks minus one is fills the entire racks register with once again.
You can also use this to learn this registers.
You can also open the Nasm cheat sheet.
You can find that in anywhere.
So you can use that to learn about these registers as well.
So here after that we move racks Keyboard Keenan one.
This loads the value of Keenan into racks.
So we are in this here we are overwriting the previous value of racks and move keyword to Num2 racks.
This stores the value of racks into enum to.
And the lastly mov rax 123456.
This loads the immediate value of 123456 in Rax.
And lastly, what we have here actually we need to instead of using that we need to use mov s mov.
Move here.
So.
Move.
Or still here?
Yes.
This.
This here needs to move here.
So move.
SD So this instruction loads double precision floating point number from the memory location key M3
into Xmm0 register.
And also keep in mind that must is a special instructions for handling floating point number because
in Q and M3 we have the floating point number which is 3.14, and after that we just have several instructions.
So this is here, these instructions here mov rsp rbp pop rbp here.
So these instructions perform the function Epilogue Storing the stack pointer, rsp and base pointer
are to their original values.
This ret instructions is new to us here.
This RET instruction is new to us.
This instruction returns from the main function which we didn't actually use that.
Lecture.
So please also keep in mind that this code is.
The x86 64 assembly language and syntax.
While I explained individual lines, it's important to make sure that code is properly assembled and
executed with a within a suitable environment.
And now what we're going to do is we will first compile it with the make.
We will create the make file in the next lecture and we will also use the triple dee dee dee dee debugger
for debugging our application, which obviously this this will not provide any console output like printing
the words Hello world, but it actually does operations in memory which we will uh, analyze that and
debug that in next lecture.
So I'm waiting you in next lecture.