1 00:00:00,400 --> 00:00:02,800 In the realm of assembly language programming. 2 00:00:02,830 --> 00:00:09,220 The JL instruction, which stands for Jump if Less, is a fundamental tool for controlling the flow 3 00:00:09,220 --> 00:00:14,320 of execution within a program based on a specific comparison condition. 4 00:00:14,470 --> 00:00:20,140 Assembly language is a low level programming language that closely corresponds to the architecture of 5 00:00:20,140 --> 00:00:23,440 a computer's central processing unit CPU. 6 00:00:23,470 --> 00:00:30,640 The JL instruction serves as a crucial role in the decision making process of a program, enabling it 7 00:00:30,640 --> 00:00:37,540 to dynamically alter its course of action, depending on whether one value is less than another. 8 00:00:37,570 --> 00:00:42,610 So here's a comprehensive breakdown of how JL instruction operates. 9 00:00:42,640 --> 00:00:46,630 The first is comparison comparison. 10 00:00:46,660 --> 00:00:51,550 The second is conditional assessment. 11 00:00:53,630 --> 00:00:54,200 Last month. 12 00:00:54,350 --> 00:00:58,040 And the third is branching. 13 00:00:59,990 --> 00:01:06,040 And here in comparison, initially a comparison operation takes place between two values. 14 00:01:06,050 --> 00:01:11,990 These values could be stored in registers, memory locations, or even immediate values embedded directly 15 00:01:11,990 --> 00:01:13,370 in the instruction. 16 00:01:13,370 --> 00:01:19,580 And here the result of the comparison dictates whether the jump occurs or not. 17 00:01:20,120 --> 00:01:26,360 So should the condition less than hold true, the program execution flow will divert to a new memory 18 00:01:26,360 --> 00:01:32,420 location, usually indicated by a label or memory address, and in branching, the actual branching 19 00:01:32,420 --> 00:01:35,870 or jump takes place if the condition is met. 20 00:01:35,990 --> 00:01:37,640 Should the condition be false? 21 00:01:37,670 --> 00:01:43,220 The program proceeds with a sequential execution without any shift in its flow. 22 00:01:43,900 --> 00:01:49,990 And now, as we do always, we will also develop a program for this, uh, execution here. 23 00:01:49,990 --> 00:01:52,520 And now let's begin it. 24 00:01:52,540 --> 00:02:01,570 So again, we will start with the defining two variables section in data section, section data, the 25 00:02:01,570 --> 00:02:05,140 value one and value two The value one. 26 00:02:05,140 --> 00:02:12,310 We will allocate memory for value one and initialize it with 15 value one DB 15. 27 00:02:12,310 --> 00:02:21,430 And in value two we will allocate memory for value two and initialize it with 20 value two DB 20 And 28 00:02:21,430 --> 00:02:25,450 after that we will also develop this write this section text. 29 00:02:27,650 --> 00:02:30,230 Section text and. 30 00:02:31,200 --> 00:02:31,740 Here. 31 00:02:31,950 --> 00:02:33,720 We will define this. 32 00:02:33,720 --> 00:02:34,890 Start here. 33 00:02:35,100 --> 00:02:36,390 So move. 34 00:02:39,380 --> 00:02:40,580 Value one. 35 00:02:41,560 --> 00:02:50,560 So here, move the value at memory, address value one into the Al and move B move the value at memory 36 00:02:50,560 --> 00:02:54,460 address value two into B al. 37 00:02:54,610 --> 00:02:57,250 So value two. 38 00:02:57,430 --> 00:03:07,090 And after that we will compare the values in Al and b cmp al, l and g l. 39 00:03:07,120 --> 00:03:08,320 This is for jump. 40 00:03:08,320 --> 00:03:14,800 If less we are now less here jump to less. 41 00:03:14,830 --> 00:03:18,520 If here we are telling the assembly jump to less. 42 00:03:18,520 --> 00:03:29,590 If a al is less than b l and here we will firstly define the not less label for now, not less. 43 00:03:29,590 --> 00:03:39,100 So your code here for the case when value one is not less than value. 44 00:03:39,200 --> 00:03:42,040 Two cmp done. 45 00:03:42,050 --> 00:03:51,590 So we are telling jump to done to conclude this section and we will also write this label and also we 46 00:03:51,590 --> 00:03:58,970 will write the less when this in less we will write the your code here. 47 00:04:00,050 --> 00:04:08,360 Here for the case when value1 is less than value to. 48 00:04:09,450 --> 00:04:11,460 And also we will write done. 49 00:04:11,460 --> 00:04:15,210 And after that, I will explain all of this here. 50 00:04:15,750 --> 00:04:19,080 And this is just a regular exit code. 51 00:04:19,080 --> 00:04:20,550 You can also add or. 52 00:04:21,900 --> 00:04:24,120 More developed a sexist quotes here. 53 00:04:25,130 --> 00:04:28,670 So this is just a project for explanatory purposes. 54 00:04:28,970 --> 00:04:34,730 And as we delve into the code, we start by defining this data section here. 55 00:04:34,730 --> 00:04:36,110 Memory is load. 56 00:04:36,140 --> 00:04:40,520 I'll allocate it for two variables Value one and value two. 57 00:04:40,550 --> 00:04:49,460 The DB directive indicates that each of these variables holds a byte size value, so we initialize value 58 00:04:49,460 --> 00:04:53,420 one with 15 and value two with 20. 59 00:04:53,630 --> 00:05:00,590 Setting the stage for our comparisons and transitioning to the text section where executable instructions 60 00:05:00,590 --> 00:05:01,470 reside. 61 00:05:01,490 --> 00:05:06,370 The Start label marks the entry point to our program, as you know. 62 00:05:06,380 --> 00:05:14,000 So we begin by using this move instruction to load the value residing in memory at the address pointed 63 00:05:14,000 --> 00:05:18,700 to by value one into a register. 64 00:05:18,710 --> 00:05:26,340 Similarly, the Move instruction transfers the value from the memory location pointed to by value two 65 00:05:26,880 --> 00:05:29,550 into the B register. 66 00:05:29,550 --> 00:05:36,030 Subsequently, the CMP instruction compares the value stored in A, L and b L. 67 00:05:36,060 --> 00:05:46,920 If the comparison reveals that the value in L is less than the value in b, l, we proceed to the less 68 00:05:46,920 --> 00:05:47,790 label. 69 00:05:47,790 --> 00:05:56,700 And should the comparison result indicate that the value in L is not less than the value in b l, we 70 00:05:57,270 --> 00:05:59,820 proceed to not less section. 71 00:05:59,820 --> 00:06:07,890 So here we here you will generally insert your custom set of instructions to handle scenarios where 72 00:06:08,040 --> 00:06:10,080 value one is not less than value. 73 00:06:10,080 --> 00:06:10,710 Two. 74 00:06:10,890 --> 00:06:20,130 Following this GMP done here so GMP done instruction allows us to skip directly to the done label as 75 00:06:20,190 --> 00:06:24,090 we also define this bypassing this less section. 76 00:06:24,090 --> 00:06:31,320 And conversely, when the comparison confirms that the value in L is indeed less than the value in b, 77 00:06:31,320 --> 00:06:33,510 l, we advance to the less label. 78 00:06:33,690 --> 00:06:41,580 So within this segment you will typically insert the instructions to be executed when value one is less 79 00:06:41,580 --> 00:06:42,360 than value. 80 00:06:42,360 --> 00:06:53,280 Two and our journey concludes at the done label here signifying signifying that the end of our program 81 00:06:53,280 --> 00:06:59,610 logic and this is typically where you would include instructions for program termination or any necessary 82 00:06:59,610 --> 00:07:00,180 cleanup. 83 00:07:00,180 --> 00:07:08,190 So this could encompass system calls to conclude the program or to release any resources incurred during 84 00:07:08,190 --> 00:07:09,060 execution. 85 00:07:09,620 --> 00:07:14,990 And by meticulously examining this assembly code, we have delved into the world of conditional branching 86 00:07:14,990 --> 00:07:21,710 and comparisons, the code flow branches based on the outcome of the comparison between value one and 87 00:07:21,710 --> 00:07:22,490 value two. 88 00:07:22,520 --> 00:07:29,270 You understanding your understanding of this branching mechanisms and comparisons will be pivotal as 89 00:07:29,270 --> 00:07:34,190 you advanced in your exploration of assembly programming. 90 00:07:34,280 --> 00:07:40,400 Embrace the learning process, continue practicing and venture deeper into the intricacies of assembly 91 00:07:40,400 --> 00:07:41,030 programming. 92 00:07:41,030 --> 00:07:42,920 So I'm waiting you in the next lecture.