1 00:00:01,680 --> 00:00:06,800 Today we'll take a look at how to write if else statements in assembly 2 00:00:11,300 --> 00:00:19,450 go ahead and download this new file from the resource section and visit India for some projects for 3 00:00:19,490 --> 00:00:27,120 Folder 0 4 if else statement this is a then and zip it 4 00:00:32,010 --> 00:00:37,350 and then delete these if and opened a new folder 5 00:00:40,540 --> 00:00:45,080 open the if else and file 972. 6 00:00:51,230 --> 00:00:51,520 All right. 7 00:00:51,550 --> 00:00:54,340 So this is a sample of an in-house House program. 8 00:00:55,790 --> 00:00:56,800 Let's run it. 9 00:00:56,960 --> 00:00:58,970 See what he does. 10 00:00:59,060 --> 00:01:13,900 Click run compile and the ever knew far he AC has changed directory to this whole clean copy. 11 00:01:13,960 --> 00:01:28,630 Open your mind from the spacebar and paste the bar and enter to enter the new directory type idea to 12 00:01:28,660 --> 00:01:35,030 check the contents of this territory and this is the file you want to run. 13 00:01:35,030 --> 00:01:42,410 So the time I followed by that time again and then press enter. 14 00:01:44,300 --> 00:01:52,830 So you are asked to enter a number so I enter six not five minutes into five 15 00:01:57,000 --> 00:01:59,910 has run the program again. 16 00:01:59,910 --> 00:02:00,650 Let's enter. 17 00:02:02,490 --> 00:02:04,880 And it is you enter five. 18 00:02:05,160 --> 00:02:10,670 So this program checks where you're at five on five. 19 00:02:10,680 --> 00:02:11,420 So let's take a look. 20 00:02:15,210 --> 00:02:18,840 Oh here we have the strings. 21 00:02:19,470 --> 00:02:22,710 Three strings under the isolation. 22 00:02:22,860 --> 00:02:28,760 Very display internal string to probably use it. 23 00:02:28,850 --> 00:02:30,650 A number. 24 00:02:30,770 --> 00:02:38,490 Then you have message one string to give out the message saying you entered Phi and then on a message 25 00:02:38,660 --> 00:02:49,350 call a message to to show the message string not five and then oh here you have to you show variables 26 00:02:49,380 --> 00:02:52,810 needed by Windows API. 27 00:02:52,810 --> 00:02:56,730 And here is where we print the message. 28 00:02:56,730 --> 00:03:05,030 Using a print function to print industry which is here and to a number 29 00:03:07,950 --> 00:03:10,880 and then you get any input handle like before. 30 00:03:11,460 --> 00:03:19,670 And then you read the input whatever input you enter you'll be safe in the industry. 31 00:03:20,190 --> 00:03:20,640 Oh here 32 00:03:23,880 --> 00:03:36,720 next you use the string to and saying long function to convert this input string into a number base 33 00:03:36,720 --> 00:03:47,750 10 number and the result of that conversion is starting E X and then you go to the next but it is the 34 00:03:47,750 --> 00:03:57,920 new but just adding up we compared the number in years to five. 35 00:03:58,610 --> 00:04:01,740 So the CMB from 50 reset into zero. 36 00:04:03,020 --> 00:04:04,940 So it does reflect a set. 37 00:04:04,970 --> 00:04:14,360 It means that he sees you go to Phi so this one test whether the 0 effect set. 38 00:04:14,500 --> 00:04:27,600 So every sentence means that yes is equal to five therefore he will jump to this label equal five. 39 00:04:27,630 --> 00:04:34,090 And here you will move message one into yes I say this one he's 40 00:04:38,190 --> 00:04:38,810 in that fight. 41 00:04:42,080 --> 00:04:51,130 So we move the message one want to yes I because we want to show this message. 42 00:04:51,130 --> 00:05:00,630 After that we move on to the output result label where really push the yes I push it stack and then 43 00:05:00,640 --> 00:05:09,920 we can bring it to show their message so yes I is actually storing in message one so many copying it 44 00:05:10,490 --> 00:05:22,900 we show you enter fi now let's come back to hear again let's save your wonderful game again and this 45 00:05:22,900 --> 00:05:33,790 time we do not end the fight how we enter and a number six so six we start in a string and convert it 46 00:05:33,790 --> 00:05:39,360 into a number by using string to unsigned long. 47 00:05:40,570 --> 00:05:41,860 And that's number six. 48 00:05:41,860 --> 00:05:43,650 We start in he acts. 49 00:05:44,650 --> 00:05:56,030 And here you compare the to five again six escapes a fight this time your comparison will not only true 50 00:05:56,120 --> 00:06:07,090 because he has six so in this case the jungler not taken and therefore he will move on to the next instruction 51 00:06:08,330 --> 00:06:15,200 so in the next instruction he will move the message two into Yes I. 52 00:06:15,630 --> 00:06:17,570 So this is actually the house but 53 00:06:21,120 --> 00:06:22,590 so I just base here. 54 00:06:25,650 --> 00:06:33,080 So this is a but if you execute if this part is not true. 55 00:06:33,630 --> 00:06:42,540 So evil is good despite my movie message to 2 yes a message to ease the string not fight 56 00:06:46,980 --> 00:06:53,390 so no once the has been assigned a not five string. 57 00:06:53,670 --> 00:07:04,640 He would then jam to the output result label and then he would bring the message starting year site 58 00:07:05,600 --> 00:07:14,990 which is the message string not five so the syntax or the structure of the IDF statement is like this 59 00:07:16,410 --> 00:07:26,700 we have a comparison or a test or some subtraction or addition operation and then followed by and jumped 60 00:07:26,700 --> 00:07:31,960 us so they dumb either be taken or not taken. 61 00:07:32,740 --> 00:07:41,620 So it just comparison is produces the same one which is true by setting a zero flat to one then he really 62 00:07:41,620 --> 00:07:45,350 jump Jamie's jump. 63 00:07:46,390 --> 00:07:49,770 You can also reduce it which means the same thing. 64 00:07:49,880 --> 00:07:59,350 If the test here fails then he went on Gem instead he will go to the else but so any else but here we 65 00:07:59,430 --> 00:08:04,320 will execute and then he will jump to the help of his. 66 00:08:05,680 --> 00:08:12,910 So we need to jump here because if we don't you will fall through and execute this line. 67 00:08:13,060 --> 00:08:15,870 That is why the jump is necessary. 68 00:08:16,510 --> 00:08:25,390 So this is the structure of a if else statement which you can use whenever you write a program that 69 00:08:25,390 --> 00:08:28,360 needs to make some kind of decision. 70 00:08:28,360 --> 00:08:30,100 So that's all for this lesson. 71 00:08:30,100 --> 00:08:30,520 Thank you. 72 00:08:30,520 --> 00:08:31,030 Harding.