Hello, this is Dr. Miller, and this
is Episode fifteen point one of
Assembly today
we're going to talk about 64 bit
assembly. We'll talk about the
Register's deprecated instructions
and then calling functions.
So 64 bit recently,
so what is 64 bit assembly?
Well, a 64 bit references, a number
of bits that are used for memory
addresses.
So when we use 64 bits, that
allows us to address two to the
sixty four minus one bytes of
RAM.
And this is equivalent to 16
exabytes.
Now, that is to be contrasted with
30 to be so 30 to bit allows
us to address two to the 30 to
minus one bites of RAM or four
gigabytes.
And so a lot of computers
nowadays have the ability to
have more than four gigabytes of
RAM. And so you have to use a 64 bit
OS in order to
use that.
There is an extension called Pache
that will allow you to address more
than four gigabytes, but
it's just easier to use a 64 bit
processor.
And then our registers are adjusted
for 64 bit assembly.
So they are larger sized and
we have more registers
and then things like push and pop.
Those stack operations are then
adjusted based on those new sizes.
So one of the other things
that was created was processer,
cause that's sort of the same time
that we had 60 bit we also
had multiple CPU's per processer,
and so the cause
would have a shared memory.
And then they allow your computer
to do what we call
multi programing or multiprocessing,
and that's for the ability for that
computer to do more more than one
thing at a time.
Before we had multicore
processors, if you just had a single
core than the processors would
switch in between different things
as fast as it could in order for
it to appear like you were watching
a video and listening to music and
editing a document at the same time.
And then the core two duo was one of
the first ones. And so this was in
2006.
So this is a desktop processor
that was used by Apple
and that sort of brought
in multiple cores and then 64
bit chips.
Now the chips, even though
they're sixty four bit, have the
ability to run thirty
two big code. So they maintain
backwards compatibility if needed,
and then our core counts have gone
up. So Core two duo had two
processors and then
they had Quad Core and Aikau
16 core.
Now we're up to thirty two or sixty
four cores that can
be on some of the new rising chips.
Now the operating system will
basically select which cause in
order to run a process on and
then we have a process where the
processor or the OS will
migrate over the stack and the
registers. So those have to be saved
and then restored if you're moving
it to another core, that might not
be on the same day.
So registers.
So instead of the E prefix,
we have the R prefix.
So instead of IEX,
we have RSX Urbex asks
RDX, we have ARCI
Ardai Arbie RSP
and then instead of Flagg's, we have
our flags.
And then instead of IP, we have our
IP.
Additionally, they added another
set of registers, so our eight
through our 15.
So instead of trying to make
up more letters, they just picked
numbers because that was easier.
And then we also added a new
addressing mode, so our IP
allows memory relative addressing
so you can have memory
addresses that are based on the
current instruction pointer.
And so this will make code that can
be more portable,
much easier in 64
bit versus 30 to bit.
So here is a diagram
that I pulled from Wikipedia
that has all of the different sets
of registers on a 64 bit OS,
and we can see that we have
some of the ones we're used to.
So Ebix
IDEX and they're smaller breakdowns.
But we also have Aaargh!
Our X Urbex asks
RDX.
We see our floating point
processor's here.
We're going to see some status bids
over here, some
special tables.
So CCDs, yes,
SS those are in there.
And then you've got your additional
R registers.
So straight through our 15 that
are included in there.
And then we have some examine them.
Why MMN and ZMM
registers that are in there and
we'll talk about those, some of
those a little bit later so we can
see that we have more registers
available to us that we can use
in order to do programing.
So one of the things we need to talk
about is deprecated instructions,
so, for example, a couple of
instructions that are deprecated our
push aid and pop aid.
So if we look inside of our library
functions and our normal main
functions, we use push aid and pop
aid to push all the registers and
then pop them back off.
And so all of the library functions
are not going to work.
So in the ASML include,
none of those functions will work
because they all rely on this push,
aid, pop and set
of instructions.
Now calling functions.
So when we have 60 Forbert,
we have the ability to use vast
calls, the most modern Aussies
are going to use what's called fast
call. So instead of pushing things
on to the stack where the stack
is much slower than
normal, RAM, we're just going to use
registers for him.
So if you only have a few
arguments, then those arguments
can be put in registers and it'll
actually execute much faster because
is is orders of magnitude slower
than the processor.
And so if we can avoid
having to hit RAM, then it's going
to go a lot faster.
So, for example, Linux uses the
first six integer or pointer
arguments are passed in Ardai,
RSI, RDX arcs
and then are eight and are nine.
And then if you have more beyond
that, then they have to go on top of
the stack.
Additionally, a lot of new
versions of Dixie rely
on libraries like printf right,
so up is in a shared library.
It's in standardly standard.
And so if you're going to use some
of the new versions of JC,
you have to use what we call pick
code or position independent code.
And that is used to create a pie
or position, independent,
executable.
And what these are doing is they
allow the different parts of the
program to actually lie in different
parts of RAM, and that helps
with things like address, base
layout, randomization, Asla
to be able to relocate that
executable in a quick fashion.
And so they're going to be a couple
of things that we might have to do
depending on what you're doing.
You might have to do that in order
to create your code.
So here there's a couple of things
to point out here.
So if we see at the top, we can
see that we are able to create a
code word.
So I got feed beef, B feed
in a code word, and then
when we're loading it, we can use
RSI and so we can load
the whole 64
bits of that into RSI.
So the memory load will actually
load all of that in there.
And then here I wanted to print off
64 bits and hex.
So the L X is
for a long
hexadecimal zero 16.
So zero means we have leading zeros
and then 16 means that you're going
to have 16
hex digits that get printed off
and then we have to move things
appropriately. So our format
string or testing is
going to go into Ardai,
the value is going to go into RSI.
So that's the first argument
for that format.
String for print F with
print. If you have to set out to
zero and then we can call print
F, but one of the things
with the position independent code
is that we have to
talk about the plot.
So the T is the
the procedure linking table.
And so what this does is it provides
a mechanism to resolve dynamic
libraries.
And so some of the versions
of JC will require
you to say WRP or with
respect to the party
or with reference to the plot.
So that way it knows where to look
up the printout function call.
It's something that we haven't had
to worry about previously.
But if you're going to do some of
the newer versions using sixty four
bit, then you have to use those type
of references.
If you're coding something and see
that it'll automatically
put in those references
appropriately.
And then we can see here, I've
removed the push aid and
the pop aid, and then
as with our normal function, we can
move into zero and exit.
I also did change this, so it's just
a main function.
So if you do that, if you
create just a main function, then
you are able to just compile
the entire thing with me
after you create your file.
So here's the example, Makefile,
for creating that, and so
they do Nazem and then minus
F will specify the file type.
And so instead of just saying lf
we say F sixty four, so this is to
make a sixty four bit
object file
and then we can use
in order to compile that because
we had a main in there, we don't
have to have the driver.
C we can just directly compile
that and it'll create our binary
fifteen point one for
that example.
So today, we talked about 64 bit
assembly, we talked about the
additional registers, some of
the deprecated functions that we
can't use in our library anymore.
And then a couple of things that we
had to know in order to call some
library functions if
we want to use some newer versions
of.
So looking forward, we're going to
talk about Memex.
We'll talk about Ezy and
then A-s and I.
If you have questions, you can email
me, Milham, J.R.
Ewing, Canada, Edu, and you can find
me on Twitter at House 30.