Hello. This is Dr Miller, and this is Episode 11.3 of Assembly.
Today, we're gonna discuss some of the arm basics, and this will include math operations and then the movement of data.
So from the arm docks, 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 operandi.
And then we can also have a an immediate value. And so some of that it for math operations. We can do our ad ad with Kerry. Subtract,
reverse, subtract superior, tracked with Carrie and reverse attract with Carrie. So typically,
um, from this, you'll end up using add or subtract, or the basic ones that you'll end up using
and then armed data movement.
So when we move data, we can use M. O V.
And so this will copy into a registered the operandi. We want to move into it. So that might be another register.
So here we can see Move R one R zero so r zero gets copied into our one.
move rd so destination some immediate value until that's just a
a number that we can move in there. So we moved the number 32 into our nine. So probably one of the biggest things that catches most of my students is just forgetting the, um
Either some kids call it hashtag or others called the Octo Thorpe or,
is another name for it.
And then we also have em the end. So move and invert. So it will basically,
um, take the number two here and inverted, and so turn it into negative to moving that into our one.
Um 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 103 into our zero move. The number 44 toe are one,
and then with our ads. So we end up using our zero. But we could use a different registered refugees are too. But in this example, we're using our zero so r zero gets the value of
are zero post are ones. I take ours there on our one Add them together and then store the result in R zero.
And then when we're done, we can say branch with link to print int. So I don't print off the number that we have done by adding those two together.
And then we can see that we have a push in a pop of the Link Register, which we saw in the previous see 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 x 86
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 arm, 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 memories. LD R Load register
and str is store register.
So listen a load data from a register from memory into a register in this will store memory from register into memory,
and so if you look again the armed docks, they have a lot of different of these. And we're going to go through the pre index and post index,
um, later on. But basically we have an operation which could be load or store.
Um and then this is double wide and so we can use this to do it. And so for operation, it's either load or store.
RT is the registered to loader store, Um and then rt to is if we have a double word. So we have to have twice a much space.
We can add an offset, and we'll talk about that when we talk about a raise. And then we got bites, signed, bites half words and signed half words.
And again, that's a lot of documentation. But that's what is on the arm site. So what kind of break it down a little bit easier. So,
for example, if I want to get the address of X
registered 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 say that 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.
Um, when we're dealing with arm
and then here we can see we're doing an ad. And again we have our destination is different than these. So add,
um, we're gonna get R one plus R to add those together and store that in or zero
and then we're done. We can do a branch of link to print into and print the result.
Um, and then we're done. We can do a pop and, um, return from our program. So let's try toe quickly and put this program.
So here's our data section.
Tell it to align to four by boundaries. The variable X is a word
It will declare our variables and our functions
is our function main.
So go ahead and push our
But the end will pop
We'll get the address of X
and then get the value of the data pointed to buy X.
Make sure you put the HASHTAG in front of here,
Then call our function print int.
So it takes 35 adds 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 tune 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 brain Jing.
So how do you load a register from my memory address
And then how do we add R one and R two and save it in our three
add R three, R one and r two. The order really doesn't matter.
So if you have questions, you can email me Miller MJ at you and Kate I e d u. And you can find me on Twitter at No House 30