13 hours 15 minutes
Hello. This is Dr Miller, and this is Episode 11.10 of Assembly.
Today, we're going to do an armory example and using indexes.
So our array example. So what's our problem To be solved.
So what we're gonna do is we're going to create two strings and then we're gonna 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.
These air ask e. And this is this.
I'll put an exclamation point, a nice new line in there and able to find our next message.
so we'll want to push our registers
and pop them.
That's only one will need.
And so then what we're gonna do is we're gonna go ahead and load our messages into registers, so load the addresses
going to use our one for the 1st 1
and I'll just use our five for the second,
what we'd like to do is we would like to check for a null terminator that will tell us when we need to stop. So we'll go ahead and use move use are too
tohave are no Terminator, which is a zero.
Okay, And then we'll have our loop here. Here's the top of our loop. When we're all done,
go ahead and print off our string.
So we're gonna print off string, too. But we're gonna copy the data from String one,
so we should get string one.
so in our loop, at some point at the end, we'll branch back up to the top,
and then 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 to so we can use LD R
We're just gonna load a bite.
We'll use our zero will be where we're gonna write it to.
We'll copy the data from our one,
and then we want to have a right back when we're done until increment by one.
That's for a character.
And then, in order to store the data, we want an eye right back into
So store bite
are zeros where we loaded the data
and then we're going to use our five,
and then we also have a right back of one. And so this will automatically upto date pointers in our one in our five
to the new locations.
And then after we've written, the data you need to compare
are zero and are too to see if they're equal.
And so we'll branch if they're equal to label done, and then if they're not equal here, no branch back up to the top.
And so, as you can see, unlike our normal examples, we don't have to update our one and are fine, Frank, because we have the right back, which will ensure that the pointer gets updated by the appropriate amount. Here, we're doing bites. So we're only in committing by one
for each one of these. So this should copy all of the characters in this string to this string,
um, while putting in a no 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 load and store
operations in order to make sure that the pointers got updated.
In the future, we're gonna look at loading and storing multiple registers from to and from memory.
If you have questions, you can email me Miller, MJ at you and Kate I e. To you, and you can find me on Twitter at No House 30.