WEBVTT

00:01.140 --> 00:05.050
Let's discuss, compare and jump instructions in this video.

00:05.550 --> 00:12.380
So far, we have written our programs in assembly language to demonstrate compassion and jump instructions.

00:12.390 --> 00:17.220
I have written a very simple SI program named Jump Si.

00:18.390 --> 00:20.120
So let's take a look at the program.

00:20.520 --> 00:25.410
I have saved this file inside the direct card siempre Dasht Jambi.

00:26.040 --> 00:29.130
Inside this I have a file called Jump Dart.

00:29.130 --> 00:31.740
See, it's a very simple SI program.

00:32.460 --> 00:37.230
If you observe the program, it's a simple program with if ands condition.

00:37.830 --> 00:39.090
Let's go from the beginning.

00:39.510 --> 00:42.420
First we have initialized to variables.

00:42.720 --> 00:50.580
Variable error is initialized with value tool and the variable B is initialized with value.

00:50.580 --> 01:00.120
Three if is equal to be, the statement will be executed and the string is equal to be will be printed.

01:00.900 --> 01:07.890
If these two are not equal, the jump will be taken to this block and the string is not equal to be

01:08.130 --> 01:09.270
will be executed.

01:09.810 --> 01:12.630
This is all fine and easy to understand in C language.

01:12.990 --> 01:18.000
Let's see what is happening behind the scenes by going through the assembly version of this program

01:18.210 --> 01:19.140
using Jilib.

01:19.680 --> 01:30.690
Let's first compile this program and using GTC jump dot c bargepole jump.

01:33.520 --> 01:39.830
We should now have the binary jump, we can check that using less there you go.

01:40.240 --> 01:46.720
Now let's open it up using GDB and I'm going to set up a breakpoint at the entry point of this program.

01:47.170 --> 01:51.310
And the entry point of this program is going to be the main function.

01:51.790 --> 01:55.390
So type Jalabi dot slash jump.

01:56.690 --> 01:59.530
And let's set up a breakpoint at Main.

02:00.680 --> 02:01.250
There you go.

02:01.760 --> 02:05.370
Now let us run the program and let us go through the disassembly.

02:06.020 --> 02:09.620
I'm typing right here it is.

02:09.630 --> 02:12.270
This is the disassembly that we are going to execute now.

02:12.290 --> 02:14.540
Currently, we are inside the main function.

02:15.060 --> 02:20.870
Now, let's quickly do our business men to see the full view of the disassembly.

02:21.890 --> 02:22.470
Here it is.

02:22.490 --> 02:24.440
This is the complete main function here.

02:25.380 --> 02:29.160
Let's execute this program until we reach this instruction.

02:29.720 --> 02:34.850
We can either set up a breakpoint here or we can type site multiple times.

02:35.390 --> 02:36.590
Let me die type ASI.

02:42.450 --> 02:44.980
All right, so we have reached this instruction.

02:45.240 --> 02:52.200
We are currently at Maine plus 12, if you closely observe the next instruction to be executed, it

02:52.200 --> 02:54.900
is placing the value to onto the stack.

02:55.410 --> 02:59.870
We can spot that by looking at the register are B in the instruction.

03:00.480 --> 03:03.630
So let's step aside and observe the stack.

03:04.380 --> 03:10.430
If you examine the stack before executing this instruction, the value to doesn't exist on the stack.

03:10.770 --> 03:15.120
So let's step aside and look at that.

03:15.270 --> 03:18.420
The value of two is currently placed on the stack.

03:19.050 --> 03:25.790
Now once again, the next instruction to be executed is placing the value tree on the stack.

03:26.460 --> 03:33.300
So I'm typing aside once again and let's observe what happens on the stack after executing this instruction.

03:36.510 --> 03:40.280
Look at that, the value tree is actually placed on the stack as well.

03:41.630 --> 03:45.710
Look at that, the value tree is now placed on the stack as well.

03:46.370 --> 03:48.080
OK, next instruction.

03:49.300 --> 03:56.680
If you observe the next instruction to be executed, once again, it is referencing a value that's available

03:56.680 --> 04:03.220
on the stack, if you notice the value that it is looking for is are B, B minus zero X eight, which

04:03.220 --> 04:06.460
is essentially this, which means the value to.

04:07.180 --> 04:11.380
So it is moving the value to into the register X..

04:12.010 --> 04:14.860
So let's first check the value of our X.

04:17.180 --> 04:27.110
Currently, this is the value of Addicks, if you say it should contain the value to let's say let's

04:27.110 --> 04:28.750
go back and check X.

04:30.420 --> 04:38.850
Dirigo Artex register now contains the value to now let's move on to the next instruction, the next

04:38.850 --> 04:46.380
instruction is comparing the value available in extra stir with some value that's available on the stack.

04:46.880 --> 04:50.040
If you notice this R, B, B, minus zero X four.

04:51.030 --> 04:56.220
Here it is, which means 063 is what it is comparing it against.

04:56.730 --> 05:02.880
So the X is currently holding two and the value of three is currently available on the stack.

05:03.120 --> 05:09.260
And this assembly program is basically checking if these two values are equal or not.

05:09.900 --> 05:13.560
And this instruction is comparing those two values.

05:14.220 --> 05:21.720
In the C program we were doing a comparison by doing if A equals to be in assembly, the instruction

05:21.750 --> 05:24.300
CMB is used for comparisons.

05:25.050 --> 05:28.440
So essentially two is being compared with three.

05:28.650 --> 05:34.860
And based on the result of this instruction, the control will be transferred into some location using

05:34.860 --> 05:37.820
the next instruction, which is Jayanthi.

05:39.180 --> 05:41.780
We will come to this Jaynie instruction in a bit.

05:41.790 --> 05:44.530
Let's first step aside and hit enter.

05:47.490 --> 05:54.060
Now if you look at the zero flag, it is not set when sampi instruction gets executed.

05:54.300 --> 05:58.200
It essentially makes a subtraction of these two values.

05:58.500 --> 06:02.000
When you do two minus three, the result is non-zero.

06:02.430 --> 06:04.950
If there isn't, a zero zero flag will be set.

06:05.190 --> 06:09.180
If the flag is set, you should see this word zero in uppercase.

06:09.900 --> 06:15.240
Since the flag is not that you are seeing it in the lowercase, but if you look at the same flag, this

06:15.240 --> 06:19.340
is set because two minus three is going to produce a negative sign.

06:20.310 --> 06:24.210
Now, what we are interested in is the next instruction, which is Jayanthi.

06:24.780 --> 06:28.860
Since these are not equal, we are going to take a jump to some location.

06:29.370 --> 06:31.230
Obviously that is the case.

06:31.740 --> 06:35.580
We will come here and execute this conditional jump.

06:35.580 --> 06:43.020
Instructions are usually followed by a comparison instruction because this takes a jump based on a specific

06:43.020 --> 06:46.320
condition and that's usually set by Campi instruction.

06:47.250 --> 06:52.800
So simply instruction in this case did a comparison between the value to entry.

06:53.190 --> 06:57.870
And since the result was not zero, it did not set zero flag.

06:58.110 --> 07:00.590
And you can see this here as well.

07:00.960 --> 07:05.940
And the reason it shows here is this jump is taken because zero flag is not set.

07:06.750 --> 07:12.150
Now let's check with this jump is taken to let us take this jump by typing assign.

07:14.090 --> 07:21.140
And if you notice, there is a call to Prenter function soon after executing two more instructions,

07:21.300 --> 07:29.990
but before that, but before that, there is an instruction which is LTA idea and some address.

07:30.500 --> 07:33.470
LTA instruction is Lord effective address.

07:33.800 --> 07:39.890
When this instruction gets executed, the contents of the memory location are not loaded, only the

07:39.890 --> 07:43.240
effective addresses is computer and placed into the register.

07:43.730 --> 07:49.250
In this case, a clear instruction moves that effective address into audio register.

07:49.730 --> 07:52.850
So let's first check what we have at this address.

07:53.240 --> 08:00.380
So I'm just copying this slash piece and I'm just pasting it here.

08:01.730 --> 08:02.270
Look at that.

08:02.390 --> 08:06.700
We have the string is not equal to be at this address.

08:07.220 --> 08:11.130
So this address is pointing to the string that's about to be printed.

08:11.690 --> 08:14.030
So why is it being moved to RBI?

08:14.600 --> 08:20.570
That's because in 1964, with architecture, the arguments are loaded into to register.

08:20.960 --> 08:28.070
This printer function that is about to be executed contains one argument, and the first argument always

08:28.070 --> 08:30.680
gets loaded into the RBA register.

08:31.010 --> 08:37.990
And that's exactly why this is getting loaded into this idea register before we execute this printer

08:38.000 --> 08:38.570
function.

08:39.050 --> 08:48.920
So let's say and if you check the RBA register, it contains an address that's pointing to this string

08:49.520 --> 08:50.300
right now.

08:50.330 --> 08:57.420
Let's say there is a call instruction, which is basically going to execute the printf function.

08:58.250 --> 09:02.900
So if we type Essi, it is going to get into the print definition.

09:03.290 --> 09:11.000
And if you type C to continue with the execution, it is going to print is not equal to B after completing

09:11.000 --> 09:12.890
the execution of print function.

09:13.430 --> 09:19.790
Now we have briefly discussed how arguments are past when a function is executed in this video.

09:20.150 --> 09:26.390
But in the next video, we are going to discuss more details about how arguments are managed when a

09:26.390 --> 09:27.530
function call is made.

09:27.800 --> 09:33.860
The idea behind this video is to show you the CMB and conditional jump instructions.

09:34.410 --> 09:35.540
That's all for this video.

09:35.870 --> 09:37.010
See you in the next one.
