1 00:00:00,650 --> 00:00:04,590 Hello, my name is Stephan, and in this lecture you will learn about the J. 2 00:00:04,790 --> 00:00:08,900 So the assembly language instruction J which stands for Jump. 3 00:00:08,930 --> 00:00:15,710 If above is a conditional jump operation utilized in low level programming to dictate the program's 4 00:00:15,710 --> 00:00:18,440 flow based on a specific comparison condition. 5 00:00:18,470 --> 00:00:25,490 The instruction is commonly used for unsigned integer comparisons, and the J instruction serves the 6 00:00:25,490 --> 00:00:33,020 purpose of deciding whether a jump should occur depending on whether one value is strictly greater than 7 00:00:33,020 --> 00:00:34,050 another value. 8 00:00:34,070 --> 00:00:36,690 So here is how it operates. 9 00:00:36,710 --> 00:00:38,300 The first is comparison. 10 00:00:38,330 --> 00:00:43,160 The instruction initiates by performing a comparison between two values. 11 00:00:43,160 --> 00:00:50,810 These values can be present in registers, immediate values embedded within the instruction itself or 12 00:00:50,810 --> 00:00:52,430 memory locations. 13 00:00:52,430 --> 00:00:54,830 And the second is conditional assessment. 14 00:00:54,830 --> 00:00:59,880 The outcome of the comparison is used to determine whether the jump should take place. 15 00:00:59,970 --> 00:01:01,860 Specifically the J. 16 00:01:02,430 --> 00:01:10,440 The jump above instruction performs a jump if the condition above holds true. 17 00:01:10,470 --> 00:01:17,580 In other words, if the first value is strictly greater than the second value, the jump will be executed. 18 00:01:18,380 --> 00:01:22,730 And the third is jump or sequential execution. 19 00:01:23,060 --> 00:01:30,710 So should the should the condition be satisfied The program's execution flow is altered and the program 20 00:01:30,710 --> 00:01:34,920 jumps to a new location specified by a label or memory address. 21 00:01:34,940 --> 00:01:42,020 Conversely, if the condition is not yet met or not met, the program continues with its sequential 22 00:01:42,020 --> 00:01:45,020 execution without any disruption. 23 00:01:45,110 --> 00:01:52,850 So in assembly language, a instruction is commonly represented by a mnemonic, followed by an operand 24 00:01:52,850 --> 00:01:57,290 indicating the target location for the jump if the condition is met. 25 00:01:57,320 --> 00:02:09,080 So here's an example a hypothetical assembly language syntax, CMP c x, d, x here and a above. 26 00:02:10,420 --> 00:02:11,200 About label. 27 00:02:11,410 --> 00:02:22,000 So here we are comparing values in registers C and D, and with this jump to a label if C is greater 28 00:02:22,000 --> 00:02:22,930 than D. 29 00:02:23,320 --> 00:02:30,490 So in this illustration here, the program compares the values stored in integers or stored in registers 30 00:02:30,520 --> 00:02:39,940 C and D, So if the value in register C x is strictly greater than the value in register D x, the program 31 00:02:39,940 --> 00:02:44,940 will execute a jump to the memory location labeled as a bowl. 32 00:02:45,100 --> 00:02:53,000 A bowl label, if the condition is not yet is not fulfilled, which is not greater than X. 33 00:02:53,050 --> 00:02:57,880 The program proceeds with its sequential execution. 34 00:02:58,660 --> 00:03:08,530 So a j instruction alongside other conditional jump instructions like JB jump below a j e jump if equal 35 00:03:08,530 --> 00:03:15,700 and j z jump if zero which you will learn in next lectures forms the bedrock of control flow with an 36 00:03:15,700 --> 00:03:17,290 assembly language programming. 37 00:03:17,320 --> 00:03:24,490 Collectively, these instructions empower programmers to craft intricate algorithms and logical structures 38 00:03:24,490 --> 00:03:28,480 at an exceptionally low level of abstraction. 39 00:03:28,510 --> 00:03:34,750 By harnessing these instructions, programmers can create a decision based behaviors and sophisticated 40 00:03:34,750 --> 00:03:41,290 branching mechanisms that are crucial for building efficient and functional assembly language programs. 41 00:03:41,380 --> 00:03:47,530 Now, what we're going to always do in this section, we will also create an example skeleton for this 42 00:03:47,620 --> 00:03:48,520 logic. 43 00:03:49,060 --> 00:03:51,250 Now what we're going to do is. 44 00:03:52,430 --> 00:03:53,240 We will. 45 00:03:54,120 --> 00:03:56,880 Again use the defined two values. 46 00:03:58,320 --> 00:04:00,690 And continue our execution. 47 00:04:01,850 --> 00:04:04,480 By execution, I mean the writing, our codes. 48 00:04:04,490 --> 00:04:11,000 So as we always do, we will define again the section data with two values in it. 49 00:04:11,330 --> 00:04:23,450 We will allocate memory for a value one and initialize it with 2025 value, one value one TB and 25. 50 00:04:23,450 --> 00:04:30,500 And we will allocate memory for value two and initialize it with the 20. 51 00:04:33,100 --> 00:04:38,800 And also we will create a section section text. 52 00:04:40,580 --> 00:04:41,600 Action text. 53 00:04:41,600 --> 00:04:48,020 And here we will create a global global start here and in start. 54 00:04:49,250 --> 00:04:49,610 Will. 55 00:04:51,000 --> 00:04:52,490 Move, Al. 56 00:04:54,010 --> 00:04:54,790 Value. 57 00:04:54,820 --> 00:04:56,380 Value one. 58 00:04:56,770 --> 00:05:05,920 Here we are loading the value stored at memory address value one into a l here, which we will do the 59 00:05:05,920 --> 00:05:11,750 same a l register with which we will do the same for the b l as well. 60 00:05:11,770 --> 00:05:14,770 So move b l. 61 00:05:16,110 --> 00:05:23,290 Uh, value to your, uh, we are going to do load the value stored at memory address value two into 62 00:05:23,310 --> 00:05:27,900 BL registers and we will always do a l bl. 63 00:05:27,900 --> 00:05:32,370 So here we are comparing the values in A, L and b l. 64 00:05:33,370 --> 00:05:37,480 And here we will use this jump ball. 65 00:05:38,170 --> 00:05:39,690 And here we will create. 66 00:05:39,700 --> 00:05:51,770 So if l as I explained here at the beginning of this lecture, if l is a bow here is if l is above j 67 00:05:51,820 --> 00:05:56,140 a jump if a ball b l jump to the above label. 68 00:05:56,140 --> 00:06:02,290 So we will create both of these labels here, not above, above and done as we always do, but here 69 00:06:02,290 --> 00:06:04,750 we are comparing L, A and b, L. 70 00:06:04,930 --> 00:06:08,350 So let's firstly create the not a ball. 71 00:06:10,190 --> 00:06:24,950 And here your code here, your code here for the scenario when value one is not above value two and 72 00:06:24,950 --> 00:06:26,300 GMP done. 73 00:06:26,300 --> 00:06:34,640 Here we are jump to the done which we will create as label right now to finalize this section and also 74 00:06:34,640 --> 00:06:37,310 we will create above here above. 75 00:06:37,910 --> 00:06:52,430 So your code here for for the scenario when value one is above value value two and here we will also 76 00:06:52,430 --> 00:06:54,080 create a done here. 77 00:06:55,490 --> 00:06:58,790 I'm here and exit code here. 78 00:06:58,820 --> 00:07:04,280 Like we here we are all the registers and Siskel at the end. 79 00:07:04,280 --> 00:07:05,750 And after that read here. 80 00:07:05,750 --> 00:07:07,340 But we will notice here. 81 00:07:07,340 --> 00:07:13,940 So this is just a skeleton of how this jumping robot works as the previous ones. 82 00:07:14,650 --> 00:07:15,670 So that's, uh. 83 00:07:15,670 --> 00:07:21,400 So this program is not fully functional yet, but we can just add the slightly exit code, but we don't 84 00:07:21,400 --> 00:07:22,510 need that here. 85 00:07:22,780 --> 00:07:27,350 So now I will start from the beginning, as I always do. 86 00:07:27,380 --> 00:07:35,140 So we initiate this exploration by setting up this data section where memory is allocated to accommodate 87 00:07:35,140 --> 00:07:38,110 the variables value one and value two. 88 00:07:38,140 --> 00:07:46,810 So these variables take on a specific values value one being assigned 21, 20, 25 and value two taking 89 00:07:46,810 --> 00:07:55,720 on 20 forming the foundation of our comparisons and here in text section, our focal point of executable 90 00:07:55,720 --> 00:08:00,540 instructions, we encounter this Start label as our entry point. 91 00:08:00,550 --> 00:08:04,570 Our journey into code begins with the Move instruction. 92 00:08:05,430 --> 00:08:11,550 And it is a mechanism through which we transfer the value stored in memory at the address specified 93 00:08:11,550 --> 00:08:16,110 by value one and into the Al register here. 94 00:08:16,140 --> 00:08:24,660 Similarly, the subsequent MOV instruction performs a parallel action for value two loading its value 95 00:08:24,660 --> 00:08:29,430 into PL register and this process sets the stage for comparison. 96 00:08:29,640 --> 00:08:37,050 The comparison comparison unfolds through the CMP instruction, subjecting the value stored in Al and 97 00:08:38,160 --> 00:08:43,170 here if the comparison reveals that the value in Al. 98 00:08:44,070 --> 00:08:45,780 Represses the value in. 99 00:08:46,950 --> 00:08:55,290 The j jump of above instructions ushers us into the above label domain. 100 00:08:55,710 --> 00:09:00,690 In this case, as you know, the value one is 25 and value two is 20. 101 00:09:00,690 --> 00:09:04,770 And in this case the above condition will met. 102 00:09:06,160 --> 00:09:06,760 And. 103 00:09:08,800 --> 00:09:16,060 After that, in cases where the comparison outcomes refuses the notion of value one surpassing value 104 00:09:16,060 --> 00:09:17,830 to the not above. 105 00:09:17,830 --> 00:09:18,070 Here. 106 00:09:18,070 --> 00:09:21,090 In this case, it should be for, for example, ten. 107 00:09:21,100 --> 00:09:23,800 In this case, the note above will execute. 108 00:09:23,830 --> 00:09:25,000 That's it here. 109 00:09:26,140 --> 00:09:26,890 And. 110 00:09:28,180 --> 00:09:31,720 And this is your, uh, here in not above. 111 00:09:31,750 --> 00:09:40,510 This is your arena, uh, to insert instructions, catering to scenarios where value one does not outpace 112 00:09:40,510 --> 00:09:41,500 value two. 113 00:09:41,500 --> 00:09:49,870 And the journey then leads us to the lay down label marking a point of conclusion for this particular 114 00:09:49,870 --> 00:09:51,070 code segment. 115 00:09:51,190 --> 00:09:57,100 On the other hand, the above label offers a contrasting sphere. 116 00:09:57,130 --> 00:10:03,070 This is where you would typically insert instruction designed to address cases where value one is indeed 117 00:10:03,070 --> 00:10:06,910 exceeds value two, and that's it. 118 00:10:06,910 --> 00:10:16,540 After that, here we have done and here our educational odyssey reaches its pinnacle with the done label 119 00:10:16,540 --> 00:10:20,020 encapsulating the conclusion of the program's logic. 120 00:10:20,290 --> 00:10:25,480 This is the appropriate place to include instructions for program termination or any necessary. 121 00:10:27,450 --> 00:10:35,460 And by delving into this assembly code, we have traversed the realm of conditional branching and comparisons. 122 00:10:35,670 --> 00:10:41,820 Armed with the ability to discover scenarios where value one is above value two. 123 00:10:42,600 --> 00:10:48,510 Your comprehension of these intricate mechanisms is a key asset as you delve deeper into the world of 124 00:10:48,510 --> 00:10:49,710 assembly programming. 125 00:10:49,920 --> 00:10:57,120 Continue your journey exploring the intricacies and applications of assembly programming with enthusiasm 126 00:10:57,120 --> 00:10:58,320 and dedication. 127 00:10:58,470 --> 00:10:59,430 Happy Learning.