WEBVTT

00:01.260 --> 00:02.789
Hello, this is Dr. Miller, and this

00:02.790 --> 00:04.199
is Episode eight point one of

00:04.200 --> 00:05.200
assembly today

00:06.150 --> 00:07.349
we're going to talk about floating

00:07.350 --> 00:08.869
point numbers and then floating

00:08.880 --> 00:09.990
point operations,

00:11.130 --> 00:12.239
floating point numbers.

00:13.410 --> 00:14.849
So a floating point number is

00:14.850 --> 00:16.920
defined and I Tripolis seven

00:17.460 --> 00:19.650
fifty four as

00:19.680 --> 00:21.003
a number for floating point

00:21.090 --> 00:22.079
arithmetic.

00:22.080 --> 00:24.180
And then the very first bit

00:24.390 --> 00:25.589
is the assignment.

00:26.280 --> 00:27.779
And this represents whether or not

00:27.780 --> 00:29.219
the number is either positive or

00:29.220 --> 00:30.220
negative.

00:30.300 --> 00:31.499
And then after that, we have the

00:31.500 --> 00:33.299
exponents, the exponent says, what

00:33.300 --> 00:34.439
power? We're going to raise this

00:34.440 --> 00:35.440
number two.

00:35.670 --> 00:36.659
And then we actually have the

00:36.660 --> 00:38.459
number, which is called the Intesa.

00:40.780 --> 00:42.609
So, for example, if we have a single

00:42.620 --> 00:44.559
precision, no disinhibit is

00:44.560 --> 00:46.389
the first bit and then

00:46.390 --> 00:47.860
the exponent is the next eight

00:48.310 --> 00:49.899
bits. So we can see that there eight

00:49.900 --> 00:51.950
bits here and then the Mentzer

00:51.970 --> 00:53.520
is the remaining twenty three bits

00:53.530 --> 00:54.951
and that gives us a 30 to bit

00:55.060 --> 00:56.060
number.

00:57.930 --> 00:59.520
If we look at a double precision

00:59.790 --> 01:00.790
or a double in the C

01:01.650 --> 01:03.569
programing language, the first bit

01:03.570 --> 01:05.236
is a sign. But again, the exponent

01:05.760 --> 01:07.132
is the next 11 bits and then

01:07.590 --> 01:09.689
the Mentzer is the remaining fifty

01:09.690 --> 01:10.690
two bits.

01:11.400 --> 01:12.719
And so each of these gives us

01:13.230 --> 01:15.299
more precision, but it also comes

01:15.300 --> 01:17.459
at a cost of more memory

01:17.460 --> 01:18.719
that we need to use in order to

01:18.720 --> 01:19.830
store those numbers.

01:21.840 --> 01:23.369
And then the floating point unit or

01:23.370 --> 01:25.620
FPU has a built in stack

01:25.710 --> 01:27.425
and so it has its own stack that is

01:27.510 --> 01:28.950
separate from the regular stack.

01:29.610 --> 01:31.349
And for example, on an X eighty six

01:31.350 --> 01:33.629
machine, it only has eight

01:33.630 --> 01:34.769
stack registers.

01:34.770 --> 01:36.599
So zero one,

01:36.600 --> 01:37.979
two, three, four, all the way up to

01:37.980 --> 01:38.980
seven.

01:39.330 --> 01:40.889
And then each of these is actually

01:40.890 --> 01:41.709
80 bits.

01:41.710 --> 01:43.278
And so if you load a number into

01:43.290 --> 01:44.849
them and do some operations,

01:45.150 --> 01:46.914
that'll give us additional precision

01:46.950 --> 01:48.629
that will help and make sure that

01:48.900 --> 01:50.189
it can be more accurate.

01:50.640 --> 01:52.199
And one of the big things to realize

01:52.200 --> 01:53.909
with floating point is that it's not

01:53.910 --> 01:54.939
100 percent accurate.

01:55.140 --> 01:57.239
So because you're still storing

01:57.240 --> 01:58.465
numbers that could repeat

01:59.010 --> 02:00.137
infinitely, we have the

02:00.840 --> 02:02.457
ability for values to not exactly

02:03.120 --> 02:04.529
match up with what we would think of

02:04.530 --> 02:06.389
them when we're talking about

02:06.390 --> 02:07.390
decimal

02:09.150 --> 02:11.129
and then estie zero always

02:11.130 --> 02:12.370
points to the top of the stack.

02:12.510 --> 02:14.078
So it's a last in first out type

02:14.460 --> 02:15.460
of thing.

02:17.030 --> 02:18.710
So floating point operations,

02:19.910 --> 02:21.674
so, for example, if you want to load

02:21.710 --> 02:23.779
something from either memory or

02:24.230 --> 02:26.570
a register, you can use FMD

02:26.600 --> 02:27.923
for floating point load and

02:28.490 --> 02:29.839
that's loaded onto the top of the

02:29.840 --> 02:32.779
stack and then filed

02:32.810 --> 02:34.189
Satullo load an integer.

02:34.280 --> 02:35.689
And so the eye in here stands for

02:35.690 --> 02:37.189
integer. So it'll take an integer

02:37.190 --> 02:38.419
and then convert it to a floating

02:38.420 --> 02:39.349
point.

02:39.350 --> 02:40.918
You can load the constant one or

02:41.180 --> 02:42.944
zero if you need those on top of the

02:43.040 --> 02:44.040
stack.

02:45.810 --> 02:47.219
And then when we go in store, we can

02:47.220 --> 02:48.220
say 40, so floating

02:49.050 --> 02:50.324
point store that will copy

02:51.000 --> 02:52.529
it from the floating point stack

02:52.530 --> 02:54.569
into the regular stack or

02:54.570 --> 02:56.099
into regular memory, depending on

02:56.100 --> 02:57.100
where you're doing it.

02:57.480 --> 02:58.859
And then we have this notion of

02:58.860 --> 03:00.530
having the ability to pop.

03:00.540 --> 03:01.949
So if you see a command like

03:02.910 --> 03:04.770
50 P,

03:05.100 --> 03:06.717
that means it's going to store do

03:06.990 --> 03:08.705
the first part and then pop off the

03:08.790 --> 03:09.790
stack. And so one

03:10.650 --> 03:11.729
of the things you want to make sure

03:11.730 --> 03:13.079
is that you don't just keep pushing

03:13.080 --> 03:14.369
things onto the stack forever

03:14.370 --> 03:15.829
because then it will break things.

03:16.740 --> 03:18.059
So we have the same thing for an

03:18.060 --> 03:19.619
integer so we can take a floating

03:19.620 --> 03:21.270
point and copy it to an integer

03:21.720 --> 03:23.189
and we can also pop it off of the

03:23.190 --> 03:24.190
stack.

03:25.150 --> 03:26.679
And then some of the math operations

03:26.680 --> 03:28.346
that we can do, we can see that we

03:28.540 --> 03:29.540
have an add so zero

03:30.610 --> 03:32.374
plus the source, so I'd add that and

03:32.500 --> 03:34.100
store it on to zero.

03:34.810 --> 03:36.549
We also have the pop versions

03:37.240 --> 03:38.857
on each one of these, and then we

03:39.100 --> 03:40.325
have so we have addition,

03:40.360 --> 03:42.639
subtraction, multiplication

03:42.640 --> 03:43.640
and division.

03:44.050 --> 03:45.879
And again, each one has a P variant

03:45.880 --> 03:47.139
in order for you to pop it off the

03:47.140 --> 03:48.909
stack if you're done using the stack

03:48.910 --> 03:50.379
and you want to save it after doing

03:50.380 --> 03:51.380
that operation.

03:54.140 --> 03:55.708
And then let's just give a quick

03:56.000 --> 03:57.000
example.

03:59.300 --> 04:01.159
So here I have a simple program.

04:05.480 --> 04:07.129
So all it's doing is it has a number

04:07.130 --> 04:08.649
A and A number B, and it's just

04:09.110 --> 04:10.669
using Felda and

04:11.050 --> 04:12.979
TPE, so I'm loading it onto

04:12.980 --> 04:14.597
the floating point stack and then

04:14.600 --> 04:16.449
I'm going to go ahead and store it

04:16.459 --> 04:17.831
back into B, so I would have

04:18.470 --> 04:19.879
A and I would have B.

04:24.530 --> 04:25.789
So I can go ahead and build it and I

04:25.790 --> 04:26.929
just wanted to run this another

04:26.930 --> 04:27.930
bugger

04:29.070 --> 04:30.910
to go ahead and say GDB,

04:31.820 --> 04:33.079
and then we're going to break in

04:33.080 --> 04:34.970
Assen main

04:36.560 --> 04:37.699
and then we'll go ahead and start

04:37.700 --> 04:39.079
running. So our four run

04:40.200 --> 04:41.779
so I can step through the first two

04:41.780 --> 04:42.780
instructions here.

04:43.100 --> 04:44.569
So this should load onto the

04:44.570 --> 04:45.649
floating point stack.

04:47.120 --> 04:49.009
So if I type I for info and then

04:49.010 --> 04:50.509
float it'll show me the floating

04:50.510 --> 04:52.099
point stack and I can see that right

04:52.100 --> 04:53.100
now it has nothing.

04:53.540 --> 04:55.039
And then I'm going to go ahead and

04:55.040 --> 04:56.959
execute this FLD command.

04:59.960 --> 05:01.339
All right, so it executed that

05:01.340 --> 05:02.839
instruction, and if I want to again

05:02.840 --> 05:04.339
look at the floating point stack,

05:04.790 --> 05:07.040
I can see that the number one point

05:07.310 --> 05:09.259
nine eight or with

05:09.290 --> 05:11.029
a bunch of nines and one is stored

05:11.030 --> 05:11.899
on there.

05:11.900 --> 05:12.900
Right. We've got our sign,

05:13.010 --> 05:14.839
Almontaser, and then our sign

05:14.840 --> 05:15.920
that our exponent and then our

05:15.950 --> 05:17.180
mantis are on their.

05:18.920 --> 05:20.539
And then if we want to look at B to

05:20.540 --> 05:21.919
see that it gets saved,

05:23.840 --> 05:25.759
so I'll examine and then F as

05:25.760 --> 05:27.199
her float and then give it the

05:27.200 --> 05:28.550
address of B,

05:29.090 --> 05:30.139
we can see that it doesn't have

05:30.140 --> 05:31.140
anything.

05:31.730 --> 05:33.980
And it looks like A.

05:35.850 --> 05:37.565
It's reading the value wrong there,

05:37.680 --> 05:38.680
but that's OK.

05:40.080 --> 05:41.519
So let's do for

05:42.060 --> 05:42.869
let's see if it gets.

05:42.870 --> 05:44.129
All right. So we have one point nine

05:44.130 --> 05:45.130
nine.

05:46.590 --> 05:47.899
And so now if we do the next

05:47.910 --> 05:48.910
instruction

05:50.220 --> 05:51.839
and then look at our floating point

05:51.840 --> 05:52.840
stack, we can see

05:53.790 --> 05:54.790
that.

05:55.120 --> 05:57.009
It's still on here, but

05:57.160 --> 05:58.629
we're not actually pointing to it,

05:58.630 --> 06:00.459
so zero points to this, so

06:00.460 --> 06:01.749
it actually just leaves it on there

06:01.750 --> 06:02.828
and just moves it away

06:03.850 --> 06:04.850
from where it was.

06:06.010 --> 06:08.050
But if we go and look at B.

06:10.040 --> 06:11.810
And I got to put here for.

06:12.830 --> 06:14.539
We can see that now I got the value

06:14.540 --> 06:15.919
that it was supposed to have, so one

06:15.920 --> 06:17.240
point nine nine.

06:22.280 --> 06:23.629
So today, we talked about the

06:23.630 --> 06:25.394
floating point unit and the floating

06:25.490 --> 06:27.019
point of stack associated with that

06:27.020 --> 06:28.759
and then operations that we can do

06:28.760 --> 06:30.129
on floating point numbers.

06:30.140 --> 06:31.339
And we gave some examples.

06:32.960 --> 06:34.279
Looking forward, we're going to do

06:34.310 --> 06:36.019
more complicated floating point

06:36.020 --> 06:37.489
examples and then talk about

06:37.790 --> 06:38.950
floating point decisions.

06:38.960 --> 06:40.087
So selection statements

06:40.820 --> 06:41.899
using floating point.

06:43.600 --> 06:44.600
So here's our quiz.

06:45.080 --> 06:46.869
Floating point registered two points

06:46.870 --> 06:48.069
to the top of the floating point

06:48.070 --> 06:49.070
stack.

06:50.960 --> 06:51.960
Zero,

06:52.880 --> 06:54.829
what is the expert link for a 64

06:54.830 --> 06:56.029
bit floating point number?

06:58.650 --> 06:59.650
Eleven bitz.

07:01.390 --> 07:02.829
If you have questions, you can email

07:02.830 --> 07:04.594
me at millirems, at you and Kadiatu,

07:05.290 --> 07:06.549
Edu, and you can find me on Twitter

07:06.550 --> 07:07.629
at Milhouse 30.

