Hello. This is Dr Miller, and this is Episode 10.4 of Assembly
today. What we're gonna do is we're going to go through a string example.
So what's our problem? To be solved.
So what we'd like to do is write a program that reads in a string and then converts all of the letters in that string to upper case letters
and then prints that string as an uppercase string
and a little bit of background. So the cases of letters and asking So here is a table that I grabbed from Wikipedia
about asking, and here is showing the letter the hex value and then the binary value. For that, it's got the six or seven bits that are used in asking the additional bit we won't worry about.
And so if we look and compare the binary oven uppercase letter like a with the lower case oven A, we can see that there is only one bit that is different. So bit six for starting
accounting from the left.
So basically, if you take that bit and if you turn it into a zero, a lower case letter all of a sudden becomes an uppercase letter.
And so we're going to use that,
um, for converting these letters from lower case into uppercase
so we'll go ahead and
start our project. So I created the project directory, entered that, and now we'll go ahead and edit our program.
So the first thing we need to do is we need to scan in our string, so we'll define our scan of foam at
it is going to be a percent s. So that is for strings Terminators. During with zero,
I'm going to allocate a couple of raise, so I might as well get those done here. So we'll have A and B
We're gonna reserve some 100 bytes
for both A and B,
and then we're going to use a couple functions. So we're gonna use scan app when we're going to use sterling.
so the first thing we need to do is we need to scan our data in. We'll go ahead and use a as a reference
so we can go ahead and push,
And then we need to push our format
and then we'll call skin if
and then we got to correct the stack.
So we pushed to things on. So we had to correct it by two. Now we need to find out how long are string is. And so we scanned it into a We need to figure out how long it iss
so we again can push
call, stir Lynn,
and then add Yes, people
four to correct our stack. And now,
yea, X has how long are string is. And so we're going to use that inside of a loop, so
we'll use the standard loops and movie. See ex.
We'll just copy how long that string is,
and we'll go up here,
we'll find our label for the beginning of our loop, and then we'll loop to upper.
so we're going to use the load, string and store string. And so those both require Yes, I and e d I.
So a couple things will need to do
is we will want to move, So we're gonna copy it in to be
so be will be our destination,
and then a is gonna be our source. So we're going to read data from a using the load
load string bite. So little copy that into a L.
Now, here's the part that we have toe,
you have to figure out. So now a l has our value
that we want to turn into an uppercase letter.
And so we saw that we needed to change one bit. Probably the easiest way to do that. We want to change that one bit to a
zero. The easiest way to do that is to use the and operation so we can and l
And then if we write out what are bits are gonna look like So
we wanted to do bet ***.
So all of these, when we hand them, if we put a one in, then whatever the original is, we're going to get out.
But right here, we're putting a zero, and so always this is going to get set to zero.
And so if we take this and converted into Hex, we end up with
zero D f
And so this is a D. This is an F.
And so now we have taken that one bit
and we have turned it into a zero when it was possibly a one or possibly a zero. But we made sure that it was a zero,
and now we just need to save. So store, string, bite.
So now that will save in to be the value. So we loaded it from a we did our and operation, and then we stored it in to be And so we'll just copy the data
and then we'll go ahead and loop on upper.
So that will keep going until we get to the length of our strings. That will exclude that zero that's there.
And then we can simply print our string. You could use print off if you want. I'm just going to use Prince Jane.
I'll print a new line here at the end.
Okay. So now if we run our program
and we type in a bee's ABC
No, it looks like we crashed it.
So it looks like I missed something. Let's look and see what I missed.
So they got
I need e X there
All right, so we can see if we type in the right letters,
which have been ABC. That's what we get. We can say this is a test of our
and it looks like ours are scan f looked for, um,
spaces which then makes that a little bit difficult. So then I have to use
That's one of the
problems of using
scan. If is, it looks for by default,
a space will break it.
And so we can see that it changed all of the cases.
So there is a way. Let me see if we can fix this
to scan and look for
Oh, I see.
I'll see if I can get this right here
a new line.
So we're gonna look for all the characters that are not a new line. The new line is 10 normally types life, and,
um, and see
until let's see if that
No, it didn't like my format.
There is a format that would fix this. Um, I don't know it off the top of my head, but there is a format that you can use,
um, in scan after basically tell it to read until it gets to a,
um, new line, which is
a way that you can make it so that you could type in an entire sentence because typically by default, we were just wanting to scan a single string and not a an entire sentence.
And so that's something that we can look up. And if you look that up, then you should be able to,
um, be able to read in that string and then print it off.
All right, so today we looked at how to read a string and then how to convert it into uppercase
and looking forward will see some different C programming constructs and look at examples of how those manifest themselves in assembly. And then we'll start looking at the arm architecture.
If you have questions, you can email me Miller, MJ at you and Keita et you,
you can find me on Twitter at Milhouse 30.