WEBVTT

00:01.340 --> 00:02.869
Hello, this is Dr. Miller, and this

00:02.870 --> 00:04.219
is Episode eight point two of

00:04.220 --> 00:05.220
Assembly

00:06.050 --> 00:07.789
today we're going to write a program

00:07.790 --> 00:09.229
using floating point numbers.

00:10.740 --> 00:12.570
So here is our program description,

00:12.750 --> 00:13.949
so we're going to write a program to

00:13.950 --> 00:15.060
calculate the following,

00:15.870 --> 00:17.719
the area of a circle, which is PI

00:17.810 --> 00:19.379
squared and the circumference of a

00:19.380 --> 00:21.059
circle, and then we'll have the user

00:21.060 --> 00:22.199
enter those values.

00:26.450 --> 00:27.769
All right, so I've already created

00:27.770 --> 00:29.629
the directory, so

00:29.630 --> 00:31.100
at the top, we're going to do our

00:31.220 --> 00:33.139
definitions and so we've got a few

00:33.140 --> 00:34.339
definitions that we're going to have

00:34.340 --> 00:35.540
to put in here.

00:36.410 --> 00:38.570
So, for example, I'll enter pie.

00:43.240 --> 00:44.769
So we'll define it as a key word,

00:44.770 --> 00:45.879
because that'll give us more

00:45.880 --> 00:46.880
precision.

00:53.440 --> 00:54.440
Six.

00:55.610 --> 00:56.933
I gave some example digits,

00:57.640 --> 00:59.349
you can do some more if you'd like

00:59.350 --> 01:00.409
to do this on your own.

01:01.570 --> 01:02.889
We're going to have X, which is a

01:02.890 --> 01:04.469
value that these are going to enter

01:04.760 --> 01:06.328
and we'll start that off at zero

01:06.700 --> 01:07.959
and that'll be an integer.

01:09.190 --> 01:10.190
The area

01:12.580 --> 01:14.739
that is going to be a floating

01:14.740 --> 01:16.119
point numbers. So we'll define it as

01:16.120 --> 01:18.180
a keyword so that it has 64

01:18.190 --> 01:19.190
bits.

01:23.010 --> 01:25.410
Here's our circle or circumference.

01:27.980 --> 01:29.744
Go ahead and find that is also a key

01:29.840 --> 01:31.010
word, zero,

01:31.910 --> 01:33.409
and then I'm just going to define

01:33.410 --> 01:35.459
the number two, we'll

01:35.480 --> 01:36.480
use that later.

01:38.720 --> 01:39.529
All right. And then we've got a

01:39.530 --> 01:40.699
couple of different formats.

01:40.700 --> 01:42.019
So one is first ganef.

01:45.060 --> 01:47.370
So the finest bites.

01:53.130 --> 01:54.480
And then our print format.

02:07.010 --> 02:08.010
And then F is

02:09.020 --> 02:11.388
the format specified

02:11.420 --> 02:12.420
for printing off

02:13.340 --> 02:15.220
a floating point number here,

02:15.230 --> 02:17.449
we had 10 for our new line

02:17.450 --> 02:18.450
and then zero,

02:20.260 --> 02:21.740
we got a couple of externals.

02:24.010 --> 02:25.010
SCANA.

02:27.840 --> 02:28.870
Parent

02:30.730 --> 02:31.730
Beth.

02:32.610 --> 02:34.620
All right, so now we're ready to

02:34.650 --> 02:35.759
go into our program.

02:35.790 --> 02:37.309
So, first off, I have to I have

02:37.710 --> 02:39.539
to add the pointer to

02:39.540 --> 02:40.589
the scanner format.

02:41.340 --> 02:42.810
So that is I'm going to push X

02:43.440 --> 02:44.440
for that.

02:48.280 --> 02:50.529
Pusha format and then call

02:51.780 --> 02:52.780
scan if

02:54.160 --> 02:56.399
and then after that, X

02:56.410 --> 02:58.599
should have the value that we

02:58.870 --> 02:59.739
care about.

02:59.740 --> 03:01.090
So that's the number that we're

03:01.210 --> 03:02.729
going to use for our radius.

03:02.740 --> 03:04.299
I guess R might be a better term,

03:04.300 --> 03:05.300
but I'm using X,

03:07.330 --> 03:08.859
so because we push two things, we

03:08.860 --> 03:10.029
have to correct the stack.

03:13.170 --> 03:14.444
OK, now put a comment here

03:15.000 --> 03:16.000
so we know.

03:21.390 --> 03:22.390
All right, next

03:23.250 --> 03:25.229
step is to load our

03:25.230 --> 03:27.020
data onto the floating point stack,

03:27.030 --> 03:28.139
so the first thing that I'm going to

03:28.140 --> 03:29.580
do is I'm going to go ahead and load

03:30.180 --> 03:31.180
PI.

03:33.190 --> 03:34.659
So I thought the floating point

03:34.660 --> 03:36.729
load, this is a cue

03:37.780 --> 03:39.819
word and I'm going to load

03:39.820 --> 03:40.820
PAE.

03:43.110 --> 03:44.999
And then I want to multiply

03:45.000 --> 03:47.129
that by X, but X is an integer,

03:47.130 --> 03:49.129
so F I am

03:49.130 --> 03:50.600
more so floating point integer

03:51.210 --> 03:52.210
ml

03:53.340 --> 03:55.589
we're using a D word for X,

03:57.450 --> 03:58.450
so I'm pi.

03:58.770 --> 04:00.180
Times are, times are.

04:00.210 --> 04:01.289
So I'll just go ahead and multiply

04:01.290 --> 04:02.290
again.

04:04.890 --> 04:05.890
OK, so now I

04:06.780 --> 04:08.699
have my result, it should be on top

04:08.700 --> 04:10.289
of the stack, so I took

04:10.710 --> 04:12.425
pie and then I multiplied it and it

04:12.510 --> 04:14.309
replaced that on top of the stack.

04:15.210 --> 04:17.129
And so this is calculating my

04:18.209 --> 04:19.209
area.

04:21.350 --> 04:23.489
So now I need to save that floating

04:23.490 --> 04:24.568
point store and then P

04:25.560 --> 04:27.389
is for Pop because I don't

04:27.390 --> 04:28.769
want that to stay on the stack.

04:32.220 --> 04:34.290
Go ahead and draw that in area

04:35.580 --> 04:37.709
and then so I used pie

04:37.710 --> 04:39.089
here as

04:39.750 --> 04:41.249
just a number that I typed in,

04:41.730 --> 04:43.259
but there is also a

04:44.430 --> 04:46.080
floating point load

04:46.680 --> 04:48.248
pie which will actually load pie

04:48.510 --> 04:49.510
on top of the stack.

04:50.550 --> 04:52.369
And then so

04:52.380 --> 04:54.299
the the circumference

04:54.300 --> 04:56.549
is to pie are so I've got pie

04:56.550 --> 04:58.229
and I need to multiply that by two.

05:02.040 --> 05:03.750
So I have my number two,

05:05.090 --> 05:06.854
OK, and then I need to multiply that

05:07.170 --> 05:08.170
by X, which

05:09.060 --> 05:10.060
is our radius.

05:10.860 --> 05:12.449
That's also an integer.

05:15.700 --> 05:17.019
And then I need to

05:19.020 --> 05:20.170
know, here we are.

05:26.330 --> 05:27.650
Doing that calculation

05:29.900 --> 05:31.020
and then we need to store that.

05:31.370 --> 05:33.470
So we went to a floating point

05:34.460 --> 05:35.660
store and pop.

05:37.530 --> 05:38.699
It's a key word.

05:41.100 --> 05:42.389
And they're just telling it how big,

05:42.390 --> 05:43.860
so that way it knows what to write.

05:45.730 --> 05:48.040
And this is circumference.

05:49.360 --> 05:50.979
All right, so now comes the fun part

05:50.980 --> 05:52.899
of trying to print

05:52.900 --> 05:54.664
these off. So because these are cute

05:54.910 --> 05:56.625
words, I have to basically push two

05:56.680 --> 05:58.089
things onto the stack.

05:59.080 --> 06:00.939
So we're going to do printing here.

06:03.810 --> 06:05.649
So with this, we need to

06:05.850 --> 06:07.519
I'm going to move into X

06:08.400 --> 06:10.139
value at circumference

06:11.010 --> 06:12.149
plus four

06:13.050 --> 06:14.220
so that get me.

06:15.120 --> 06:16.688
Four of the bites and then I can

06:16.980 --> 06:18.209
push that onto the stack

06:19.170 --> 06:20.579
and then I need to

06:21.630 --> 06:23.160
move into X

06:25.070 --> 06:26.940
value at circumference, so I get

06:26.970 --> 06:28.230
me the other four bites

06:29.760 --> 06:31.109
and I have to push that onto the

06:31.110 --> 06:32.110
stack.

06:34.990 --> 06:36.160
So here we're loading

06:37.510 --> 06:38.510
circumference and

06:39.490 --> 06:40.929
now we want to do the same thing for

06:40.930 --> 06:42.279
the area, so remember, we have to do

06:42.280 --> 06:43.239
them a reverse order.

06:43.240 --> 06:44.439
So that's why we did circumference

06:44.440 --> 06:45.440
first.

06:46.120 --> 06:48.309
Yak's area

06:48.460 --> 06:49.479
was for

06:51.430 --> 06:52.809
pushbacks,

06:53.920 --> 06:54.920
yak's

06:56.200 --> 06:57.200
area, valuate

06:58.480 --> 07:01.360
area pushbacks.

07:02.780 --> 07:04.179
And then we're going to have to

07:04.900 --> 07:05.900
push our format.

07:08.110 --> 07:09.139
And it's called P for

07:09.940 --> 07:10.940
Perens

07:12.700 --> 07:15.010
and then we're going to call PRAnd.

07:17.230 --> 07:18.669
Now, if we go back, we're going to

07:18.670 --> 07:19.779
have to count how many things we

07:19.780 --> 07:21.009
pushed on the stack for this

07:21.010 --> 07:23.650
printing. So we got one,

07:23.890 --> 07:26.500
four, eight, 12,

07:27.370 --> 07:28.370
16.

07:28.750 --> 07:30.399
I missed my X here.

07:33.020 --> 07:34.020
16 in

07:34.970 --> 07:37.309
decimal, which is 10 and Hex

07:37.310 --> 07:38.388
right here and then 14

07:39.230 --> 07:41.149
hex, so to correct the stack,

07:41.150 --> 07:42.439
we have to do add

07:44.420 --> 07:46.670
14, add to E.S.P

07:46.910 --> 07:48.290
14 hex.

07:49.550 --> 07:51.019
And so that's a correct to stack for

07:51.020 --> 07:53.089
all the things that we pushed

07:53.090 --> 07:54.769
on the stack for our printing.

08:01.820 --> 08:03.089
And it looks like I have an error,

08:03.090 --> 08:04.230
so let's go and fix that.

08:10.360 --> 08:12.670
Floating point

08:14.380 --> 08:15.910
parents put some letters their.

08:23.180 --> 08:24.920
And we messed one of them up, OK?

08:24.940 --> 08:26.312
So it says the area is zero,

08:26.900 --> 08:27.900
circumference is 60,

08:28.880 --> 08:29.880
200.

08:32.230 --> 08:33.896
So let's go back and double check,

08:34.059 --> 08:35.059
so.

08:46.580 --> 08:48.799
Oh, floating point or

08:48.920 --> 08:49.920
C area.

08:52.290 --> 08:53.830
That should be a cue word.

08:56.080 --> 08:57.080
Marigot.

09:02.610 --> 09:04.409
All right, so it looks like we got

09:04.410 --> 09:06.080
the right results.

09:09.230 --> 09:10.999
So as you can see, some of the

09:11.330 --> 09:12.800
debugging steps you have to go

09:13.100 --> 09:14.659
through and figure out which line

09:14.660 --> 09:16.130
you might have an error on and

09:16.700 --> 09:17.925
go and see what operation

09:18.830 --> 09:20.149
that you might have missed.

09:20.420 --> 09:22.459
So we could see that I had a typo.

09:22.490 --> 09:23.599
I've had a couple of typos,

09:24.860 --> 09:26.429
but going through at least December

09:26.450 --> 09:28.214
will tell you that there is an error

09:28.220 --> 09:29.599
and then you can go back and figure

09:29.600 --> 09:31.730
out where that error exists.

09:36.640 --> 09:38.829
So today, we built our example

09:38.830 --> 09:40.929
program and then you saw that that

09:40.930 --> 09:42.639
was used in order to

09:43.570 --> 09:45.159
demonstrate how we can load a

09:45.160 --> 09:46.659
floating point numbers and then now

09:46.660 --> 09:48.070
we can print those off.

09:49.570 --> 09:50.649
So in the future, we're going to

09:50.650 --> 09:51.728
talk about conditions.

09:51.960 --> 09:53.332
So making decisions based on

09:53.350 --> 09:54.519
floating point numbers.

09:55.880 --> 09:56.979
If you have questions, you can

09:56.980 --> 09:57.980
contact me via email

09:58.960 --> 10:00.430
at Miller, MJ, at Uncrated Edu

10:01.210 --> 10:02.950
and on Twitter at know how sturdy.

