WEBVTT

00:01.190 --> 00:02.599
Hello, this is Dr. Miller and this

00:02.600 --> 00:03.769
is Episode ten point two of

00:03.770 --> 00:04.770
Assembly.

00:07.050 --> 00:08.460
Today, we're going to

00:08.940 --> 00:10.859
create an example using an array.

00:12.060 --> 00:13.519
So here's our example,

00:14.220 --> 00:15.550
so what's our problem to solve?

00:15.690 --> 00:17.159
So what we want to do is we want to

00:17.160 --> 00:18.420
retain a list of numbers.

00:18.660 --> 00:20.179
We will then want to add all of

00:20.280 --> 00:21.629
those numbers together and then

00:21.630 --> 00:23.519
print the sum and we'll do all

00:23.520 --> 00:25.379
of these operations using an

00:25.380 --> 00:26.380
array.

00:29.250 --> 00:30.524
All right, so I've already

00:31.110 --> 00:33.329
created my project and I'm editing

00:33.330 --> 00:35.159
that project, so

00:35.160 --> 00:36.329
the first thing we need to do is

00:36.330 --> 00:37.330
define our way.

00:37.860 --> 00:39.909
So I'll just call it A

00:40.470 --> 00:41.989
and then we're going to read in

00:42.360 --> 00:43.199
all the values.

00:43.200 --> 00:44.915
And so we'll go ahead and use ready

00:45.150 --> 00:46.740
to reserve a bunch of D words,

00:47.370 --> 00:48.900
actually allocate five of them.

00:51.480 --> 00:52.589
All right. So the first thing that

00:52.590 --> 00:53.609
we want to do is we're going to

00:53.610 --> 00:55.276
probably use a loop in order to go

00:55.470 --> 00:57.050
through and read these five numbers.

00:57.090 --> 00:59.280
So we'll go ahead and move into X,

01:00.450 --> 01:02.039
the number five, which is how many

01:02.040 --> 01:03.089
elements are going to be in our

01:03.090 --> 01:04.756
array. We're going to use Ebix for

01:05.019 --> 01:06.019
our offset.

01:07.580 --> 01:09.148
We'll start that off at zero and

01:09.620 --> 01:11.239
then we're going to use a loop, so

01:11.240 --> 01:12.680
we'll call this our read loop

01:13.370 --> 01:15.200
at the bottom, we're going to loop

01:15.350 --> 01:16.639
to read.

01:18.290 --> 01:19.969
All right. So what we'll want to do

01:19.980 --> 01:21.830
is we'll want to call,

01:23.180 --> 01:24.739
read, end

01:25.010 --> 01:26.749
to read an integer that will store

01:26.750 --> 01:28.040
it in X

01:28.640 --> 01:30.257
and then we can go ahead and copy

01:30.470 --> 01:32.580
X into our array.

01:32.930 --> 01:34.310
So we're going to move

01:34.850 --> 01:36.026
our is called A and then

01:36.680 --> 01:38.720
our offset is Ebe X

01:40.280 --> 01:41.269
and then the value we're going to

01:41.270 --> 01:43.239
copy in there is X,

01:43.730 --> 01:45.069
so go ahead and copy the value of

01:45.070 --> 01:47.150
VACC into our array

01:48.620 --> 01:49.900
and then each time through.

01:49.910 --> 01:51.819
So just got to double check.

01:51.890 --> 01:53.390
We're using Ebix for our

01:54.530 --> 01:55.902
offset and each time we need

01:56.450 --> 01:57.979
to add the appropriate amount to the

01:57.980 --> 01:59.669
offset. So here we're using these

01:59.690 --> 02:01.700
words and each word is four bytes.

02:01.710 --> 02:03.950
So we'll go ahead and add to SBX

02:04.670 --> 02:06.409
for each time through the loop.

02:08.600 --> 02:10.168
So now we need to sum all of our

02:10.639 --> 02:11.509
numbers together.

02:11.510 --> 02:13.249
So we've read them all into our ray.

02:13.910 --> 02:15.889
We've stored them and now we want

02:15.890 --> 02:17.719
to go ahead in some

02:17.720 --> 02:19.190
them. So, again, we're going to

02:19.340 --> 02:20.749
we're going to use a

02:22.340 --> 02:24.529
loop here and we'll use X,

02:24.530 --> 02:26.147
so we'll go ahead and move into X

02:26.870 --> 02:28.009
then. Number five.

02:29.940 --> 02:31.379
And then what we want to do is we

02:31.380 --> 02:32.556
want to load the values,

02:33.300 --> 02:34.300
so

02:35.580 --> 02:37.319
we will do that inside of our loop.

02:37.350 --> 02:38.967
We'll have to figure out what the

02:39.000 --> 02:39.959
offset is.

02:39.960 --> 02:42.030
Some move into IDEX,

02:43.230 --> 02:44.749
the offset which we're going to

02:45.210 --> 02:46.379
set at zero.

02:55.550 --> 02:57.049
And we'll go ahead and call this our

02:57.050 --> 02:59.330
summary, so we're going to loop

03:01.370 --> 03:03.289
to some and this

03:03.290 --> 03:04.290
will be some.

03:07.420 --> 03:09.699
We also want to use a variable

03:09.700 --> 03:11.415
in order to store the sun, so we'll

03:11.560 --> 03:13.179
just go ahead and use X,

03:13.840 --> 03:15.460
so we'll set to zero.

03:25.770 --> 03:26.799
All right, so there's

03:27.630 --> 03:28.589
a couple of different ways we could

03:28.590 --> 03:30.479
do this. I'll show you the first way

03:30.480 --> 03:32.700
so we could just add into Yak's

03:33.030 --> 03:34.869
and then we need to grab our

03:34.870 --> 03:35.870
array A plus

03:36.930 --> 03:37.930
our offset, which is

03:39.270 --> 03:40.270
IDEX.

03:41.430 --> 03:42.851
We could add that directly or

03:43.380 --> 03:44.380
we could use

03:45.330 --> 03:47.100
this. We could move

03:47.250 --> 03:49.229
into SBX that

03:49.230 --> 03:50.230
value.

03:54.450 --> 03:56.259
And then add yak's

03:56.280 --> 03:57.389
and SBX.

04:01.990 --> 04:03.970
And then each time through,

04:04.000 --> 04:06.489
we need to increment

04:06.610 --> 04:08.619
our offset.

04:12.890 --> 04:14.017
So we are using IDEX as

04:14.960 --> 04:16.381
our offset, so we need to add

04:16.850 --> 04:18.739
for each time we do

04:18.740 --> 04:19.740
that and then

04:20.720 --> 04:22.690
our goal was to print off the sum.

04:23.870 --> 04:25.360
So we'll go ahead and use printf.

04:26.030 --> 04:27.304
So the first thing that we

04:27.890 --> 04:29.899
want to do is maybe define our

04:29.900 --> 04:30.900
format.

04:33.690 --> 04:36.059
This is

04:36.060 --> 04:38.129
and will use Precent D

04:39.300 --> 04:40.329
terminate our format,

04:41.490 --> 04:43.169
which again is a string, which is an

04:43.170 --> 04:44.609
array, and we talked about how that

04:44.610 --> 04:46.049
should be terminated by zero.

04:47.880 --> 04:49.203
We also want to we're going

04:49.740 --> 04:50.699
to use printf.

04:50.700 --> 04:52.079
So we want to say X

04:52.620 --> 04:54.740
turn print

04:54.760 --> 04:55.760
F.

04:56.800 --> 04:58.419
And then inside of here, we will go

04:58.420 --> 04:59.829
ahead and push.

05:00.550 --> 05:02.350
So that was our son that we had to

05:02.440 --> 05:03.640
push our format,

05:05.770 --> 05:06.910
call Prenter,

05:07.780 --> 05:09.009
because we that's what we want to

05:09.010 --> 05:09.929
function. We want to call.

05:09.930 --> 05:11.199
And we have to correct our STAC.

05:13.130 --> 05:14.690
So ad for the E.S.P.

05:15.880 --> 05:17.889
I'm sorry, eight

05:18.670 --> 05:20.259
push on two parameters, not just

05:20.260 --> 05:21.260
one.

05:22.820 --> 05:25.070
All right, let's see if this works.

05:27.380 --> 05:29.749
All right, so play into the numbers.

05:32.530 --> 05:34.519
One through five, we got 15.

05:34.570 --> 05:36.220
Let's make one small correction,

05:36.770 --> 05:38.410
let's put a new line in here.

05:40.680 --> 05:42.359
So that way it prints that off.

05:45.290 --> 05:47.509
One, two, three, four or five.

05:47.870 --> 05:49.370
And if you add those all together,

05:49.400 --> 05:50.689
you should get the number 15.

05:54.680 --> 05:56.346
So today, we gave an example using

05:56.750 --> 05:58.465
an array we went through and loaded

05:58.670 --> 06:00.336
values into the array, and then we

06:00.410 --> 06:02.209
also read values from that array

06:02.990 --> 06:04.759
and then called our print

06:04.850 --> 06:05.850
function.

06:06.630 --> 06:08.069
So looking forward, we'll talk about

06:08.070 --> 06:09.569
string operations and different

06:09.570 --> 06:11.339
functions that you can run on

06:11.340 --> 06:12.340
string's.

06:13.040 --> 06:14.449
If you have questions, you can email

06:14.450 --> 06:16.699
me Miller, MJ at you in KSTU

06:16.700 --> 06:18.019
and you can find me on Twitter at

06:18.030 --> 06:18.829
Milhouse 30.

