Hello, this is Dr. Miller, and this
is Episode eleven point ten of
Assembly.
Today, we're going to do an armory
example and using indexes.
So our example.
So what's our problem to be solved?
So what we're going to do is we're
going to create two strings and then
we're going to copy data from one
string into the other, and then
we're going to use our right back
functions.
So I've already set up my project,
so let's let's define our strings
here.
So these are aski and this is this.
Oh, put an exclamation point in
a nice new line in there, and it
will define our next message.
OK.
So we want to push our editors.
And Poppen.
That's all we'll need,
and so then what we're going to do
is we're going to go ahead and load
our messages into
registers, so load the addresses
we're going to use are one for
the first one.
And I'll just use R5
for the second.
OK,
and then.
What we'd like to do is we would
like to check for another Terminator
that will tell us when we need to
stop, so we'll go ahead and use to
use our two.
To have our null terminated,
which is a zero.
OK, and then we'll have our loop
here.
Here's a top of our loop when we're
all done.
Go ahead and print off our string.
So we're going to print off string,
too, but we're going to copy the
data from string one,
so we should get string one.
OK, so
in our loop, at some point at the
end, we'll branch back up to
the top
and we have to do our loading.
So what we need to do is we need to
load from message one,
the piece of data and then write it
to message two so we can use Helda
are we're just going to load
a bite.
We use our zero will be
where we're going to write it to.
We'll copy the data from our
one and then we want to have a
write back when we're done.
And so we'll increment by one
that's for our character.
And then in order to store the data,
we are going to write it back in to
register five.
So store by eight
are zeros where we loaded the data
and then we're going to use our
five and
then we'll also have a right back of
one. And so this will automatically
update the appointers in our one
in our five to the
new locations.
And then after we've written the
data, we need to compare
R zero and
R two to see if they're equal.
And so we'll branch if they're equal
to the label done and then if
they're not equal, it'll branch
back up to the top.
And so as you can see, unlike
our normal examples, we don't have
to update our one in our fine print
because we have the right back,
which will ensure that the pointer
gets updated by the appropriate
amount. Here we're doing bytes, so
we're only incrementing by one
for each one of these. So this
should copy all of the characters in
this string to this string
while putting in a null character in
there. So I made sure that my second
string was longer so that I had
plenty of room.
And as you can see, it printed off
the first string, even though when
I look at the code, reprinted off
the second string, and so
we copied the data from the first
string into the second string and
then printed it off.
So today, we saw an example using
copying of a string, and then we
used right back with our in
store operations
in order to make sure that the
pointers got updated.
In the future, we're going to look
at loading and storing multiple
registers from to and from
memory.
If you have questions, you can
e-mail me Miller, MJ at and
Aidoo and you can find me on Twitter
at Milhouse 30.