WEBVTT

00:01.470 --> 00:06.240
In this video, let's discuss some most commonly used stack instructions.

00:06.810 --> 00:08.900
Let's begin by writing a simple program.

00:09.150 --> 00:14.040
I'm going to create a new file called Push, Flash, Pop, not Nazim.

00:20.860 --> 00:29.350
And as usual, I'm going to start with a global directive, so let's type global space and let's start

00:29.920 --> 00:37.740
and let's specify this start as our entry point here and let's first write the instruction, move our

00:37.750 --> 00:39.250
eggs, comma 20.

00:41.320 --> 00:48.640
Next, let's push the value stored in this register under the stack by using the instruction push at

00:48.660 --> 00:49.150
X.

00:49.850 --> 00:55.910
So I'm typing push out X, let's push the value stored in the register under the stack.

00:55.930 --> 01:03.700
Once again I'm typing push out X and then let's use pop idea.

01:04.330 --> 01:10.450
What this instruction will do is whatever the value that we have recently pushed onto the stack will

01:10.450 --> 01:12.730
be popped into the idea register.

01:13.450 --> 01:17.140
Now let's also type pop RB X.

01:17.800 --> 01:21.880
This time the value on the top of the stack will be popped into the register.

01:21.880 --> 01:22.690
RB X.

01:23.350 --> 01:30.160
Now let's save the file and let's once again assemble and link it.

01:31.570 --> 01:48.070
Nazem pushpa dot nazeem dash o push pop dot o f l sixty four and let's say early push pop dot o bargepole

01:48.760 --> 01:50.200
push nasch pop.

01:50.950 --> 01:52.920
So that's going to be our output file.

01:54.760 --> 01:56.830
Now let's open it up using GDP.

01:57.190 --> 02:10.660
I'm typing gdb dot slash, push, dash, pop and let's set up an entry point at underscore start and

02:11.290 --> 02:12.040
let's run it.

02:14.500 --> 02:15.120
Here we are.

02:15.160 --> 02:19.840
This is the disassembly and observe what we have on the top of the stack.

02:19.840 --> 02:24.430
At this point of time we have value one on the top of the stack.

02:24.850 --> 02:29.590
Now let's type say to move the value hex falling into X.

02:30.100 --> 02:31.390
I'm typing s.A.

02:36.290 --> 02:45.830
As you can see here, the register adex contains the value hex 14 now still the top of the stack contains

02:45.830 --> 02:46.610
value one.

02:47.000 --> 02:52.680
And we are about to push the value that is stored in order to register onto the stack.

02:53.060 --> 03:00.800
So once this instruction gets executed, the value that is currently stored in our eggs will be pushed

03:00.950 --> 03:01.850
onto the stack.

03:02.240 --> 03:03.590
So let's take a say.

03:05.090 --> 03:10.700
And as you can see now, the top of the stack is pointing to the value hex 14.

03:11.300 --> 03:16.040
Now, the next instruction to be executed is one more push IREX.

03:16.490 --> 03:20.710
That means we should see another similar entry on the stack now.

03:21.050 --> 03:25.730
So let's step aside a look at that push.

03:25.730 --> 03:31.220
IREX instruction has pushed the value HEX 14 onto the stack once again.

03:31.790 --> 03:36.080
Now the next instruction to be executed is pop idea.

03:36.860 --> 03:40.750
Pop is one instruction that people always get confused about.

03:41.030 --> 03:43.040
So try to put some attention here.

03:43.430 --> 03:51.530
When you execute pop space aspecific register, what happens is whatever the value that we have on the

03:51.530 --> 03:55.560
top of the stack is going to be popped into the register.

03:56.150 --> 04:02.780
In this case, the register idea is going to contain the value hex 14 because that's the value that

04:02.780 --> 04:04.070
is on the top of the stack.

04:04.880 --> 04:08.540
So let's execute this idea before executing that.

04:08.730 --> 04:12.600
Let's quickly check the value that we currently have in our day register.

04:13.130 --> 04:14.950
If you notice, it's zero.

04:15.560 --> 04:22.260
So after executing this instruction, we should see the value hex 14 in the register idei.

04:22.700 --> 04:24.020
So let's say.

04:26.310 --> 04:33.990
And check the value of our register, if you look at this, the register ardia contains Heggs 14 this

04:33.990 --> 04:34.260
time.

04:34.890 --> 04:37.660
So that's how pop instruction works.

04:38.150 --> 04:39.170
Now, look at that.

04:39.210 --> 04:41.720
We have another pop instruction now.

04:41.730 --> 04:47.680
This time the value on the top of the stack is going to be popped into our vic's register.

04:48.090 --> 04:53.170
So let's step aside and check what happened to the RBA register before that.

04:53.280 --> 04:57.210
Once again, let's quickly check the current value of RB X register.

04:57.660 --> 04:59.210
It's currently zero.

04:59.730 --> 05:01.140
So let's take aside.

05:03.140 --> 05:11.030
And once again, let's go back and check our bags and look at that, the value X 14 is popped into our

05:11.030 --> 05:11.900
vehicles registered.

05:12.590 --> 05:15.680
This is how push and pop instructions.

05:15.680 --> 05:16.130
What?
