1 00:00:00,770 --> 00:00:05,870 Hello, my name is Typhoon and in this lecture you will learn about the jump if less or equal. 2 00:00:05,900 --> 00:00:14,030 So jump if less or equal j l e is a conditional jump instruction in assembly language programming that 3 00:00:14,060 --> 00:00:18,320 directs the flow of execution based on a comparison condition. 4 00:00:18,410 --> 00:00:25,400 This instruction is commonly used to make decisions within programs by evaluating whether one value 5 00:00:25,400 --> 00:00:28,790 is less than or equal to another value. 6 00:00:28,820 --> 00:00:34,910 It's particularly relevant in scenarios where signed integer comparison is involved. 7 00:00:34,940 --> 00:00:41,330 So the first stage here, the instruction follows this general process. 8 00:00:41,390 --> 00:00:43,070 The comparison. 9 00:00:43,190 --> 00:00:48,760 The instruction begins by performing a comparison between two values. 10 00:00:48,770 --> 00:00:55,220 So these values would be stored in registers, memory locations or immediate values. 11 00:00:55,940 --> 00:00:57,440 The instruction itself. 12 00:00:59,000 --> 00:01:00,650 The second is conditional check. 13 00:01:00,680 --> 00:01:07,420 The result of the comparison is then used to determine whether the jump should occur in the case of 14 00:01:08,150 --> 00:01:10,880 the jump will take place if either of two. 15 00:01:11,990 --> 00:01:12,320 Matt. 16 00:01:13,630 --> 00:01:20,830 So the first is the first condition is the zero flag is there. 17 00:01:20,890 --> 00:01:24,040 Zero flag is set to one. 18 00:01:24,460 --> 00:01:36,880 This indicating that the values are equal or the sign flag is F sign flag and the and overflow flag. 19 00:01:37,560 --> 00:01:46,850 Like have have the same value, so indicating that the result is negative or equal. 20 00:01:46,860 --> 00:01:47,670 So. 21 00:01:50,510 --> 00:01:51,320 Equal. 22 00:01:52,560 --> 00:01:53,490 And. 23 00:01:58,400 --> 00:02:00,920 There are negative. 24 00:02:01,570 --> 00:02:05,080 And or negative or equal. 25 00:02:07,590 --> 00:02:15,300 And the last is if either of the conditions mentioned above is satisfied, the program's execution flow 26 00:02:15,300 --> 00:02:22,260 is altered and it jumps to a new location specified by a label or memory address. 27 00:02:22,290 --> 00:02:29,910 If the conditions are not met, the program continues executing the subsequent instruction sequentially 28 00:02:29,910 --> 00:02:33,360 without any alteration to its flow. 29 00:02:33,780 --> 00:02:38,640 Now we will, as we always do in this section, we will write another code. 30 00:02:39,030 --> 00:02:40,980 Uh, considering. 31 00:02:41,750 --> 00:02:42,340 This. 32 00:02:42,440 --> 00:02:48,890 Um, and we will build project something like jump if less or we will use this, uh, jelly here. 33 00:02:49,160 --> 00:02:50,480 So now. 34 00:02:51,310 --> 00:02:53,860 Let's get started with this here. 35 00:02:58,090 --> 00:03:01,390 Of course, as we always do, we will. 36 00:03:01,540 --> 00:03:02,500 Uh, firstly. 37 00:03:04,450 --> 00:03:09,070 So let's in this lecture, let's actually write our. 38 00:03:11,310 --> 00:03:13,410 Port with using. 39 00:03:13,410 --> 00:03:19,350 Yeah, we can also use this print f so we make it more functional in this lecture. 40 00:03:20,040 --> 00:03:23,730 But it might take a long time, but you will understand it better. 41 00:03:26,670 --> 00:03:30,810 Or instead of writing print f uh, which is not required at all. 42 00:03:30,810 --> 00:03:35,070 Uh, the in this lecture you will learn the logic and. 43 00:03:36,040 --> 00:03:39,190 Usage of this jar and indents. 44 00:03:39,190 --> 00:03:47,230 In next sections, we will develop our programs according to the, according to this, uh, logical 45 00:03:47,230 --> 00:03:49,060 conditions here and now. 46 00:03:49,060 --> 00:03:50,740 We will as always do. 47 00:03:51,310 --> 00:03:54,100 Uh, we will firstly define the section data. 48 00:03:54,340 --> 00:04:02,380 Uh, here in this data we will allocate memory for value one and initialize it with 15 value. 49 00:04:03,090 --> 00:04:06,480 Value of one DB and 15. 50 00:04:06,480 --> 00:04:12,990 And again, we will allocate memory for value two and initialize it to 15 again. 51 00:04:12,990 --> 00:04:18,680 And here we will create a section text Global Start. 52 00:04:18,680 --> 00:04:22,860 This is the starting point for our program and in start here. 53 00:04:24,060 --> 00:04:24,480 Art. 54 00:04:24,860 --> 00:04:25,500 We will. 55 00:04:26,340 --> 00:04:28,200 Move, Al. 56 00:04:29,850 --> 00:04:31,980 Uh, to value one. 57 00:04:34,990 --> 00:04:35,950 So we are moved. 58 00:04:36,250 --> 00:04:43,750 We are moving the value at memory address value one into the Al and we are doing the same for BL here. 59 00:04:43,750 --> 00:04:49,360 So we are moving the value at memory address value two into the BL. 60 00:04:51,610 --> 00:05:01,810 And here we are going to compare the result, compare the values in L and b, L, cmp, L and b, l. 61 00:05:02,860 --> 00:05:05,050 And we will use the jump if less. 62 00:05:05,050 --> 00:05:07,100 Or equal jelly. 63 00:05:08,380 --> 00:05:12,430 Uh, less or equal equal here. 64 00:05:12,430 --> 00:05:24,010 So here we will jump to less or equal if l is less than or equal to equal to b l, And here we will 65 00:05:24,010 --> 00:05:29,020 write note we will first create a note less or. 66 00:05:29,850 --> 00:05:31,320 Equal here. 67 00:05:31,350 --> 00:05:33,540 So your code. 68 00:05:34,170 --> 00:05:45,510 Here for the case when value one is not less than or equal to value two here. 69 00:05:45,510 --> 00:05:46,050 Right? 70 00:05:46,050 --> 00:05:56,880 So value two and we are going to jump to done done to conclude this section and we will also develop 71 00:05:56,910 --> 00:05:57,690 done here. 72 00:05:57,690 --> 00:05:59,850 Jump JMP done. 73 00:06:00,570 --> 00:06:01,470 And. 74 00:06:02,190 --> 00:06:05,970 We will create a less or equal. 75 00:06:07,290 --> 00:06:18,960 So your code here for for the case when value one is less than or equal actually. 76 00:06:21,320 --> 00:06:21,680 So. 77 00:06:24,190 --> 00:06:29,260 Is not less and here is less than or equal to value. 78 00:06:29,260 --> 00:06:34,690 One value one or value value two. 79 00:06:34,930 --> 00:06:41,530 Let's make this not uppercase to make sure shown yes less than or equal to. 80 00:06:41,530 --> 00:06:44,560 And we will create our exit code. 81 00:06:47,710 --> 00:06:51,130 And this is your exit code here. 82 00:06:51,130 --> 00:06:58,810 And in this session, we are about to embark on an in-depth journey through the assembly code here. 83 00:06:58,810 --> 00:07:00,010 And our. 84 00:07:01,010 --> 00:07:06,620 Goal is to meticulously analyze each line and unravel the logic behind the conditional branching and 85 00:07:06,620 --> 00:07:07,640 comparisons. 86 00:07:07,700 --> 00:07:11,030 So let's begin this and here. 87 00:07:12,000 --> 00:07:18,540 Our journey commences with the declaration of the data section where, um, we allocate memory to store 88 00:07:18,540 --> 00:07:21,660 two variables value one and value two. 89 00:07:21,660 --> 00:07:24,500 Both variables are initialized to 15. 90 00:07:24,510 --> 00:07:30,390 So setting the stage for our comparison again and transitioning to the text section where executable 91 00:07:30,390 --> 00:07:36,990 instructions reside, the Start label serves as our global entry point, as I always say. 92 00:07:37,410 --> 00:07:41,100 Um, and we start by employing this move again. 93 00:07:41,850 --> 00:07:48,450 Uh, move instruction to load the value residing in memory at the address pointed to by value one into 94 00:07:48,450 --> 00:07:49,800 the al register. 95 00:07:49,800 --> 00:07:56,190 Similarly, move instruction transfers the value from the memory location pointed to value two into 96 00:07:56,190 --> 00:07:57,900 the Belle Register. 97 00:07:57,960 --> 00:08:04,720 Following this instruction undertakes a comparison between the value stored in Al and b l. 98 00:08:04,770 --> 00:08:13,480 If the comparison determines that the value in Al is less than or equal to the value in b l, we proceed 99 00:08:13,480 --> 00:08:15,190 to the less. 100 00:08:16,180 --> 00:08:18,310 Or equal labor. 101 00:08:18,520 --> 00:08:24,820 So in scenarios where the comparison result indicates that the value in Al is not less than or equal 102 00:08:24,820 --> 00:08:31,600 to value on PL, we advance to the not less or equal section here. 103 00:08:31,600 --> 00:08:37,540 You will typically insert your custom set of instructions to handle cases where value one is not less 104 00:08:37,540 --> 00:08:38,920 than or equal to value. 105 00:08:38,920 --> 00:08:39,370 Two. 106 00:08:39,460 --> 00:08:41,350 Subsequently GMP. 107 00:08:42,100 --> 00:08:42,240 Uh. 108 00:08:42,310 --> 00:08:43,480 Done here. 109 00:08:43,630 --> 00:08:49,900 Uh, instruction enables us to bypass the less or equal to actually. 110 00:08:49,900 --> 00:08:50,140 Yeah. 111 00:08:50,140 --> 00:08:50,470 Less. 112 00:08:50,470 --> 00:08:51,610 Or equal to. 113 00:08:52,500 --> 00:08:57,180 Uh section and head directly to done label. 114 00:08:57,180 --> 00:09:04,830 And conversely, when the comparison, uh, confirms that the value in Al is indeed less than or equal 115 00:09:04,860 --> 00:09:09,000 to the value in B, we proceed to the less or equal label. 116 00:09:09,000 --> 00:09:15,450 So with this segment, you will typically insert instructions to be executed when value of one is less 117 00:09:15,450 --> 00:09:17,130 than or equal to value. 118 00:09:17,130 --> 00:09:17,600 Two. 119 00:09:17,610 --> 00:09:25,140 And our journey culminates at the done label marking at the end of our program Logic. 120 00:09:25,290 --> 00:09:33,240 So this is the ideal location to include instructions for program termination or any necessary cleanup 121 00:09:33,480 --> 00:09:36,840 might involve system calls or resource management. 122 00:09:36,960 --> 00:09:39,570 And that's it with our lecture. 123 00:09:39,890 --> 00:09:42,750 Uh, jump if less or equal here. 124 00:09:42,750 --> 00:09:43,530 So. 125 00:09:44,550 --> 00:09:45,420 This, actually. 126 00:09:46,930 --> 00:09:48,730 Like, almost. 127 00:09:49,780 --> 00:09:55,420 The chord structure is almost the same as previous ones, but here the logic is different. 128 00:09:55,420 --> 00:09:57,460 So I'm waiting you in next lecture.