[MUSIC].
Now I'll tell a little bit about, x86-64.
I'm also going to show you how to do the
swap example we saw in the previous
video.
But now, with, x86-64 insertions as
opposed to the 32 bit.
Instructions, okay?
So x86-64 has 16 registers, okay?
And just, just like I32, there's some
registers that have special use, but
there's a lot more general purpose
registers.
Like all of these registers here are only
present in the 64 bit of x86.
And also know that while these registers
Are 64 bits wide.
You can also access the lower 32 bits of
them as a register, as well.
For example, you know, eax, which is also
present in IA-32, is the low order 32
bits of register.
Rax in x86-64.
Okay.
So each look when we think about any
existing registers to 64 bits plus adding
eight new registers.
and now the way we look at operands in 32
versus 64 bit modes the following
Remember that we had, in, in I 32, look
at move l.
And l referred to moving 4 bytes worth of
data.
Now what we have in x86-64 is move q,
it's a new type of data size that it's 8
bytes or 64 bits long.
Okay.
Now we also have other instructions, like
addl that's presently in 32.
Now we have addq.
And then shift l and we can have shift q,
and so on.
So and also note that x86-64 can also use
all the 32-bits instructions that 30,
that generate 32-bit results.
Okay?
So ends like I showed you in the previous
slide.
We can use, we can reference the low
order 32 bits of some 64 bit registers
with the same name as we use in 32-bit
ISA.
And the, the high order 32 bits are set
to zero.
here's the example that we saw in a
previous video.
we had this swap function, that received
two pointers, xp and xy, as parameters.
And then it swaps the contents of these
pointers, okay?
remember that these two instructions
here, what they were doing is they were
reading The pointers that were stored in
the stack because parameters in the I32,
I, I32ABI passed by a, to stack.
'Kay, that's, that's one thing to note.
And we've used all movl instructions.
Because we're moving four bytes worth of
data.
Okay?
So now, let's look at how this function,
this piece of code will look like in 64
bits.
Okay, bam, the first thing to notice,
what we have, movl.
Four of them.
And also, note that we are passing the
parameters.
My registers.
Okay, so directly as opposed to this
text.
So XP, the XP parameter is stored in
register RDI.
NYP is stored in register RSI, and these
are 64 bit pointers because adversaries
in 64, in access 664 are 64 bit.
long.
And look how interesting.
Now we have only four instructions.
We're no longer reading the parameters
from the stack, which is a big advantage,
right.
So it's, it's much faster, don't have to
store it to memory and read it back.
And we have much fewer instructions.
And now here, what we're doing is this
first instruction gets the contents of
the, the of xp, and stores it in a
temporary variable.
In this case t0, right?
That happens to be mapped to adx.
We get yp, it's contents, right?
That's why we're using the parentheses
here.
We're just referencing the, the address.
Storing the other temporary variable, t1,
happens to be map, mapped to eax.
And staying with just storing the
temporary variable back into the
pointers, and then we return.
It's much simpler, right?
And because the main reason it's simpler
is because we don't have to, to use the
stack at all.
No stack operations required, and note
that we still moved.
32 bits worth of data.
Why is that?
Well, because this integer's here.
Happens to be four bytes long.
Even though the pointer itself is 64
bits, the unit of data that it points to
is a four byte.
Integer.
and, and we also use Move L tool.
Because we're moving 4 bytes of data.
We're still using the same type of
instructions.
Now suppose that we had long ends.
Now if you're saying long ends here.
We're saying that the union of data is 8
bytes here.
'Kay?
So, even if there is a byte, now the move
operation itself has to be eight bytes
long.
Remember that q refers to eight byte
words.
Okay?
So and now since the long int is eight
bytes as well, we have to use movq
instructions.
'Kay?
So, alright see you next time.
Wyszukiwarka
Podobne podstrony:
02 x86 vs x86 6406 x86 64 Procedures and Stacks06 x86 64 Procedures and StacksDP Miscallenous wnt5 x86 3202 CD P 64(sadryści vs rząd part 02) Sadr grozi otwartą wojną rządowix86 sharedreqs x86Identification of 32 bit x86 CPUs based on reset signaturegbm x86 stuff indexWinXP Pro SP3 x86 BE 2014 7 13 Valid WGA CD Keysdocs doc x86 stolen functionsWindows 8 Pro VL x86WinXP Pro SP3 x86 BE 2014 7 13 ChangelogWinXP Pro SP3 x86 BE 2014 7 13 READMEwięcej podobnych podstron