Hello, this is Dr. Miller, and this
is Episode eleven point three of
Assembly
today we're going to discuss some of
the armed basics.
And this will include math
operations and the movement of data.
So our math.
So from the armed docs, we basically
have an operator that we have
and then we can have several
different registers that
we can use so we can have a
destination register, a source
register, and then another operand,
and then we can also have a
intermediate value.
And so some of the different math
operations that we can do or add,
add with carry, subtract,
reverse, subtract,
tracked with carry and reverse,
subtract with Kerry.
So typically
from this you'll end up using add or
subtract are the basic ones that
you'll end up using.
And then armed data movement,
so when we move data,
we can use MLV
and so this will copy into
a register the operand that we
want to move into it.
So that might be another register.
So here we can see
move our one hour zero so
our zero gets copied into our one.
We can use
Movahed.
So a destination, some immediate
value. And so that's just a
a number that we can move
in there. So we moved the
number thirty two into our nine.
So probably one of the biggest
things that catches most of my
students is just forgetting
the either
some kids call it hashtag or others
call Dr. Thorpe or
Bang or hash
is another name for it.
And then we also have and
Vaughn some move and invert.
So it will basically
take the number two here and invert
it. And so turn it into negative
two.
So moving that into our one
and then we're allowed to basically
move into a different destination
than the source with
the different move operations.
So again, here's another example.
So here we can move the number one
hundred and three into our zero
move, the number forty four into our
one, and then with our
ADD. So we end up using our zero,
but we could use a different
register, we could use our two.
But in this example, we're using our
zero. So our zero gets the value
of our zero
plus our one.
So take our zero on our one, add
them together and then store the
result in R zero.
And then when we're done we can say
branch of link to print end
so that I'll print off the number
that we have done by adding
those two together.
And then we can see that we have a
push and a pop of the link register,
which we saw in the previous
lecture.
And then we're all done.
We can do branch exchange at the
link register in order to exit our
program.
So additionally, we can load data
from memory, and so
one of the differences in when we
talked about six,
we had the ability to say move
and the move command would either
move from memory or
it would move from
a register.
And so when you're dealing with ALM,
basically they have separate
commands that will load a register
from RAM or memory.
And so we have two different
commands for loading from from
memory while loading from memory is
eldard load register
and start a store register.
So listen to load data
from a register from memory
into a register.
And this will store memory from a
register into memory.
And so if you look at, again, the
arm dogs, they have a lot of
different of these and we're going
to go through the pre
index and post index
later on.
But basically we have an operation
which could be lowed or store,
and then this is double wide
and so we can
use this to do it.
And so for our operation, it's
either load or store.
R.T. is the registered to
load or store.
And then R2 is
if we have a double word.
So we have to have twice as much
space we can
add and offset. And we'll talk about
that when we talk about a raise.
And then we got bitts signed
1/2 words and signed
words.
And again, that's a lot of
documentation, but that's what is
on the armed site.
So what kind of break it down a
little bit easier.
So, for example, if
I want to get the address
of X so
I can use lowed, register
to load the address of X
into our one, and then
I can say load, register and get the
value at our ones are one
is an address. And again, I'm taking
the value at that location and
storing it here.
So this had the address of our
variable and now
when I save it, it's going to have
the value from our register.
And so any time you're going to
load something from memory, you
basically need this two step process
when we're dealing with ALM.
And then here we can see we are
doing an ad and again, we have our
destination is different than these.
So ad we're
going to get our one plus hour to
add those together and store that in
our zero.
And then when we're done, we can do
a branch with link
to print it and print the result.
And then when we're done, we can do
a pop and
return from our program.
So let's try to quickly
input this program.
So here's our data section.
Tell it to align to for my
boundaries, the variable X
is a word
has a number thirty five.
All right.
We'll declare our variables
and our functions,
so print
int and.
This is our function main,
and so here
we get rid of that,
so go ahead and push our
link register
at the end, will pop
our link register.
And we'll get the address of X.
And can get the value of
the data pointed to
by X.
Make sure you put the hashtag
in front of here.
And call our function printing's.
So it takes thirty five ads,
seven to it, and we end up with the
number 42.
All right, today today we talked
about the math operations and
then we talked about the basic
arm data movement
to and from registers and to and
from memory.
So in the future, we'll talk about
arm indexing modes and
the ability to use that with a raise
and then arm branching.
So how do you load a register from
a memory address?
We use Eldar.
And then how do we add R one
and R two and save it in our three?
At our 3:00 hour, one an hour to
the order really doesn't matter.
So if you have questions, you can
e-mail me Miller, MJ at you and
Keda, Aidoo, and you can find me on
Twitter at no House 30.