WEBVTT

00:00.830 --> 00:02.359
Hello, this is Dr. Miller, and this

00:02.360 --> 00:03.829
is Episode ten point four of

00:03.830 --> 00:04.830
Assembly

00:05.870 --> 00:07.159
today. What we're going to do is

00:07.160 --> 00:08.826
we're going to go through a strong

00:08.960 --> 00:09.960
example.

00:12.570 --> 00:14.470
So what's our problem to be solved?

00:15.060 --> 00:16.529
So what we'd like to do is write a

00:16.530 --> 00:18.149
program that reads in a string

00:18.420 --> 00:20.129
and then converts all of the letters

00:20.130 --> 00:22.079
in that string to uppercase letters

00:22.590 --> 00:23.913
and then prints that string

00:24.420 --> 00:25.710
as an uppercase string.

00:29.600 --> 00:31.459
And a little bit of background, so

00:31.610 --> 00:33.859
the cases of letters and aski,

00:33.860 --> 00:35.477
so here is a table that I grabbed

00:35.960 --> 00:37.879
from Wikipedia about

00:37.880 --> 00:39.979
Askey and here it's showing me

00:39.980 --> 00:42.049
the letter, the hex value

00:42.050 --> 00:43.599
and then the binary value for that.

00:43.610 --> 00:44.610
And it's got the six

00:45.800 --> 00:47.779
or seven bits

00:47.780 --> 00:48.939
that are used in ASCII.

00:48.950 --> 00:50.479
The additional bit we won't worry

00:50.480 --> 00:51.480
about.

00:51.820 --> 00:53.350
And so if we look and compare

00:53.710 --> 00:55.449
the binary of an uppercase letter

00:55.450 --> 00:56.450
like A with the

00:57.310 --> 00:59.139
lowercase of an A., we can see

00:59.140 --> 01:00.639
that there is only one bit that is

01:00.640 --> 01:02.439
different. So a six, the first

01:02.440 --> 01:04.509
starting counting from the

01:04.540 --> 01:05.540
left.

01:05.980 --> 01:07.959
So basically, if you take that bit

01:07.960 --> 01:09.819
and if you turn it into a zero, a

01:09.820 --> 01:11.349
lowercase letter all of a sudden

01:11.350 --> 01:12.879
becomes an uppercase letter.

01:13.480 --> 01:15.010
And so we're going to use that

01:15.910 --> 01:18.069
for converting these letters from

01:18.070 --> 01:20.360
lowercase into uppercase.

01:22.090 --> 01:23.499
So we'll go ahead and

01:24.250 --> 01:25.569
start our project. So I created the

01:25.570 --> 01:27.279
project directory, entered that, and

01:27.280 --> 01:28.479
now we'll go ahead and edit our

01:28.480 --> 01:29.480
program.

01:29.500 --> 01:30.819
So the first thing we need to do is

01:30.820 --> 01:32.230
we need to scan in our string.

01:32.650 --> 01:33.875
So we'll define our SCANA

01:34.780 --> 01:35.780
from that.

01:38.200 --> 01:40.150
It is going to be a percent

01:40.280 --> 01:41.554
s, so that is for string's

01:42.550 --> 01:44.370
Terminator's during one zero.

01:45.200 --> 01:46.629
I'm going to allocate a couple of

01:46.630 --> 01:47.799
days so I might as well get those

01:47.800 --> 01:49.074
done here. So we'll have A

01:49.780 --> 01:51.879
and B, we're going to reserve

01:51.880 --> 01:53.469
some one hundred bytes

01:54.790 --> 01:56.560
for both A and B,

01:58.900 --> 02:00.219
and then we're going to use a couple

02:00.220 --> 02:01.449
of functions. So we're going to use

02:01.450 --> 02:02.920
ganef and we're going to use

02:03.100 --> 02:04.100
Easterlin.

02:12.760 --> 02:13.760
OK,

02:14.830 --> 02:16.269
so the first thing we need to do is

02:16.270 --> 02:17.619
we need to scan our

02:18.190 --> 02:19.807
data in, we'll go ahead and use a

02:20.110 --> 02:21.286
as a reference so we can

02:22.060 --> 02:23.169
go ahead and push

02:23.980 --> 02:24.980
a.

02:26.510 --> 02:28.009
And then we need to push our format.

02:31.470 --> 02:33.020
And then we'll call SCANA

02:35.130 --> 02:36.089
and then we've got to crack the

02:36.090 --> 02:37.090
stack,

02:38.160 --> 02:39.869
so we push two things on, so we have

02:39.870 --> 02:40.879
to correct it by two.

02:41.280 --> 02:43.199
Now we need to find out how long our

02:43.200 --> 02:43.979
string is right.

02:43.980 --> 02:45.330
So we scanned it into a

02:45.810 --> 02:47.039
we need to figure out how long it

02:47.040 --> 02:48.029
is.

02:48.030 --> 02:49.860
So we again, can

02:50.460 --> 02:51.460
push

02:52.650 --> 02:54.719
a call

02:54.990 --> 02:55.990
or one

02:56.820 --> 02:58.190
and then add is

02:59.260 --> 03:01.229
for four to

03:01.230 --> 03:02.610
correct our stack and now

03:03.270 --> 03:04.495
X has how long our string

03:05.280 --> 03:06.839
is. And so we're going to use that

03:06.840 --> 03:07.619
inside of a loop.

03:07.620 --> 03:08.620
So we'll use the

03:09.720 --> 03:11.819
standard loops and move X.

03:12.720 --> 03:14.369
We'll just copy how long that string

03:14.370 --> 03:15.370
is.

03:18.180 --> 03:20.250
And we'll go up here.

03:21.940 --> 03:23.309
Will define our label for the

03:23.310 --> 03:25.229
beginning of our loop and then we'll

03:25.230 --> 03:26.849
loop to upper.

03:28.520 --> 03:30.589
All right, so

03:30.620 --> 03:32.809
we're going to use the

03:33.350 --> 03:35.240
load string and store string,

03:35.420 --> 03:37.849
and so those both require Essi

03:37.850 --> 03:38.850
and Etai.

03:39.560 --> 03:40.879
So a couple of things we'll need to

03:40.880 --> 03:41.880
do is we

03:42.860 --> 03:45.320
will want to move.

03:45.770 --> 03:47.300
So we're going to copy it into B,

03:48.230 --> 03:50.360
so B will be our destination.

03:58.910 --> 04:00.049
And then he is going to be our

04:00.050 --> 04:01.639
source, so we're going to read data

04:01.640 --> 04:03.559
from a using the load

04:05.720 --> 04:07.879
load string byte

04:08.120 --> 04:10.189
so that copy that into Al.

04:11.840 --> 04:13.580
Now, here's the part that we have to

04:14.570 --> 04:15.439
you have to figure out.

04:15.440 --> 04:17.599
So now Al has our value

04:18.320 --> 04:19.692
that we want to turn into an

04:20.089 --> 04:21.089
uppercase letter.

04:21.589 --> 04:23.089
And so we saw that we needed to

04:23.090 --> 04:24.259
change one bit.

04:24.270 --> 04:25.949
Probably the easiest way to do that.

04:25.970 --> 04:27.587
We want to change that one bit to

04:27.950 --> 04:29.759
a zero.

04:29.810 --> 04:31.429
The easiest way to do that is to use

04:31.430 --> 04:32.430
the an operation so

04:33.290 --> 04:34.670
we can and al

04:35.450 --> 04:37.339
and then if we write out what our

04:37.340 --> 04:38.589
bits are going to look like.

04:38.900 --> 04:40.819
So we wanted to do

04:40.820 --> 04:41.820
bits six.

04:43.120 --> 04:44.149
So all of these, when

04:44.980 --> 04:46.929
we hand them, if we put a one in,

04:46.930 --> 04:48.669
then whatever the original is, we're

04:48.670 --> 04:49.670
going to get out.

04:50.260 --> 04:52.029
But right here, we're putting a

04:52.030 --> 04:53.206
zero. And so always this

04:53.860 --> 04:55.269
is going to get set to zero.

04:56.360 --> 04:57.634
And so if we take this and

04:58.220 --> 04:59.599
convert it into hex,

05:00.290 --> 05:01.639
we end up with.

05:02.680 --> 05:04.199
Zero F

05:05.170 --> 05:06.170
in hex, and so

05:07.060 --> 05:08.070
this is a D.

05:08.440 --> 05:10.389
This is an F, and so

05:10.390 --> 05:12.279
now we have taken

05:12.280 --> 05:13.799
that one bit and we have turned

05:14.380 --> 05:16.269
it into a zero when it was

05:16.510 --> 05:18.669
possibly a one or possibly a zero,

05:18.670 --> 05:20.259
but we made sure that it was a zero

05:21.220 --> 05:22.739
and now we just need to save so

05:23.380 --> 05:24.999
stores during byte.

05:25.570 --> 05:27.459
So now that will save into B

05:27.610 --> 05:29.529
the value. So we loaded it from A

05:29.890 --> 05:31.779
we did our An operation and then

05:31.780 --> 05:33.699
we stored it into B and so

05:33.700 --> 05:34.899
we'll just copy the data

05:35.740 --> 05:36.740
into there

05:38.020 --> 05:39.879
and then we'll go ahead and loop on

05:39.880 --> 05:40.880
upper.

05:41.260 --> 05:42.583
So that'll keep going until

05:43.270 --> 05:44.985
we get to the length of our string.

05:45.040 --> 05:46.959
So that'll exclude that zero that's

05:46.960 --> 05:47.960
there.

05:48.400 --> 05:49.809
And then we can simply print our

05:49.810 --> 05:51.574
string. You could use print F if you

05:51.670 --> 05:52.993
want. I'm just going to use

05:53.050 --> 05:54.050
Prinstein.

06:00.990 --> 06:02.499
I'll print a new line here at the

06:02.500 --> 06:03.500
end.

06:04.180 --> 06:05.180
All right.

06:08.190 --> 06:10.560
OK, so now if we run our program.

06:12.420 --> 06:13.829
And we type in Abbi's

06:14.350 --> 06:15.350
ABC.

06:16.170 --> 06:17.660
Oh, looks like we crashed it,

06:18.840 --> 06:20.065
so it looks like I missed

06:20.730 --> 06:21.509
something.

06:21.510 --> 06:23.069
Let's look and see what I missed.

06:25.350 --> 06:26.880
So we got.

06:32.980 --> 06:35.199
Oh, I need X

06:35.200 --> 06:37.839
there mistyped.

06:43.640 --> 06:45.589
All right, so we can see if we

06:45.590 --> 06:46.609
type in the right letters,

06:47.870 --> 06:49.249
which have been ABC, that's what we

06:49.250 --> 06:51.109
get. We can say this

06:51.110 --> 06:53.329
is a test of

06:53.540 --> 06:54.540
our.

06:56.700 --> 06:58.440
Kaye's program.

07:00.040 --> 07:02.440
And it looks like ours are

07:02.620 --> 07:04.299
scanning looked for

07:05.830 --> 07:07.749
spaces, which then makes that

07:07.750 --> 07:08.619
a little bit difficult.

07:08.620 --> 07:11.410
So then I have to use this.

07:12.430 --> 07:13.430
Oh.

07:27.320 --> 07:29.449
That's one of the problems

07:29.450 --> 07:31.410
of using scan F

07:31.430 --> 07:33.230
is it looks for by default,

07:33.800 --> 07:35.119
a space will break it.

07:40.610 --> 07:41.869
And so we can see that it changed

07:41.870 --> 07:44.149
all of the cases, so

07:44.150 --> 07:45.375
there is a way let me see

07:45.980 --> 07:47.240
if we can fix this.

07:48.400 --> 07:49.400
To scan and look

07:50.380 --> 07:51.380
for.

07:54.180 --> 07:55.339
Oh, I see.

07:57.470 --> 07:58.470
No, but

07:59.300 --> 08:00.649
I'll see if I can get this right

08:00.650 --> 08:01.650
here, a new

08:02.690 --> 08:03.690
line, so we're

08:04.520 --> 08:05.839
going to look for all the characters

08:05.840 --> 08:07.579
that are not a new line.

08:07.580 --> 08:09.910
So new line is ten normally

08:09.920 --> 08:10.970
types life and

08:12.050 --> 08:13.050
in C

08:13.970 --> 08:15.439
and so let's see if that

08:16.130 --> 08:17.130
works.

08:24.860 --> 08:26.809
No, I didn't like my format.

08:32.780 --> 08:34.158
There is a format that would fix

08:34.159 --> 08:35.159
this, I don't

08:36.289 --> 08:37.788
know it off the top of my head, but

08:37.789 --> 08:39.710
there is a format that you can use

08:40.429 --> 08:42.079
in scan after to basically tell it

08:42.080 --> 08:44.089
to read until it gets

08:44.090 --> 08:45.230
to a

08:46.460 --> 08:48.380
new line, which is

08:49.280 --> 08:51.139
a way that you can make it so that

08:51.140 --> 08:52.429
you could type in an entire

08:52.430 --> 08:54.139
sentence, because typically by

08:54.140 --> 08:55.806
default, we we are just wanting to

08:55.820 --> 08:57.889
scan a single string and not a an

08:57.890 --> 08:58.890
entire sentence.

08:59.360 --> 09:01.010
And so that's something that we can

09:01.250 --> 09:02.671
look up. And if you look that

09:03.110 --> 09:04.490
up, then you should be able to

09:05.600 --> 09:07.759
be able to read in that string

09:07.760 --> 09:08.840
and then print it off.

09:12.370 --> 09:13.779
All right, so today we looked at how

09:13.780 --> 09:15.279
to read a string and then how to

09:15.280 --> 09:16.840
convert it into uppercase.

09:18.150 --> 09:19.590
And looking forward, we'll

09:20.190 --> 09:21.709
see some different C programing

09:22.020 --> 09:23.219
constructs and we'll look at

09:23.220 --> 09:24.929
examples of how those manifest

09:24.930 --> 09:27.110
themselves in assembly

09:27.420 --> 09:28.950
and then we'll start looking at the

09:29.280 --> 09:30.280
architecture.

09:31.430 --> 09:32.809
If you have questions, you can email

09:32.810 --> 09:35.000
me Miller, MJ at you in Edu.

09:35.540 --> 09:36.889
You can find me on Twitter at

09:36.890 --> 09:37.700
Milhouse 30.

