Hello, this is Dr. Miller, and this
is Episode eleven point twelve of
Assembly.
So today, we're going to give an
armload and store with multiple
operations,
so our example,
so using the load
multiple on the store multiple, it's
best to use an array.
And so what we're going to do is
we're going to use strings.
So strings are naturally arrays.
And so we're going to copy a string
from one buffer to another.
And we use LDM and strÃ¸m
and then we're going to load some
parts of a string into memory and
then do a swap on those.
So let's get our terminal open.
I've already created our project.
All right, so we're going to want to
have at least one string
message.
OK, and we'll
put a new line in there
and then we'll have our next
message.
On this alloca 100 bytes for
that one.
All right,
so we'll go ahead and save our
registers.
Mainly the link register
and restore it.
We have that there.
All right, so what we want to do is
we want to
use our load and store in
order to copy the string.
And my string just happens to be
just enough bytes that we can do the
copy very simply.
So
we will do a load register
or zero
message and
register our one
hour five.
Message one.
So now we've got our poisoners
setup.
And so if we want to load the whole
thing, we can say load
multiple
are zero and
we can store that in registers are
one. Two are four.
And now, since it's stored in R one
through our four, we can
go ahead and save it into the other
array. So SDM
are five.
Are one, two, are
four, so we will
load the data into these registers
and then store it back into
these registers.
So I a copy asking for us
and then what we'd like to do is we
want to do a swap on some of these
and so we'll go ahead and do a load
register or
zero
message
and then load multiple.
Or zero, and
we'll add it right back there,
because we're going to load it into
our one and R two,
so that'll update the pointer.
The fact that we just loaded
two full registers worth
of data.
So that would be eight bytes.
So add that to our our pointer
and then we can say load multiple
are zero.
Ah, three
oh ah three
or four,
it's our appointer got updated and
we can update this point or two if
we want, but our pointer got updated
from this operation and
it also will get updated from this
one.
And so then we can.
Load in and we're going to basically
swap these around.
So we've lowered our base address
back.
And then we're going to write these
bites back in the opposite order,
so we'll do.
ASTM, so we're going to write
into our zero with a right
back, all right, R
three and R
for.
And then we'll write our one in our
two.
Again, we're updating the pointer to
the fact that we just wrote a
bite's.
OK, so that should swap
abcde f with
g h i j k l.
In memory, and then we'll go ahead
and print off our string's.
So ladies in.
So message one.
And it needs to be done.
So we can see that we reversed
the first eight
characters with the second
eight characters, and
then we were able to copy all of the
data from this into a
another array and then print it off.
And so we successfully copied
the data and successfully able to
print it off and copied
more than just that.
But it copied the data for us.
All right.
So today's lecture we used LDM
and strÃ¸m in order to load multiple
into multiple registers,
if you have questions, you can email
me Milgrim Jayate, you ain't KSTU
and you can find me on Twitter at
Milhouse 30.