1 00:00:00,510 --> 00:00:01,570 Hello. 2 00:00:01,620 --> 00:00:09,020 Today we are going to look at looks so download this file in 0 5. 3 00:00:09,030 --> 00:00:17,620 Looks easy from the resource section for this lesson and place it in the far Sims projects folder thereafter 4 00:00:17,980 --> 00:00:18,590 and zip it. 5 00:00:23,780 --> 00:00:31,400 You may know the league is a far and open the new for the 0 05 looks 6 00:00:34,100 --> 00:00:42,380 let's open the looks here so far and let's run it to see what he does. 7 00:00:42,980 --> 00:00:54,200 Keep on run compile and now you have a new ESEA file so are going to go to this folder. 8 00:00:54,220 --> 00:00:56,760 So yes copy this tough 9 00:01:00,500 --> 00:01:14,410 and open your combine from type CV and frankly and paste the path presenter idea to list the content 10 00:01:15,010 --> 00:01:19,970 and you should see a look start ESEA file. 11 00:01:20,290 --> 00:01:21,000 Now let's run it 12 00:01:29,530 --> 00:01:31,080 presenter. 13 00:01:31,630 --> 00:01:37,140 Now enter a number let's say 3. 14 00:01:37,950 --> 00:01:42,420 PRESENTER Any prints 1 2 3. 15 00:01:42,470 --> 00:01:43,600 Let's try it again. 16 00:01:46,570 --> 00:01:48,970 Let's enter 10. 17 00:01:49,240 --> 00:01:53,460 PRESENTER Any prints 1 to 10. 18 00:01:54,650 --> 00:02:04,320 So this program asks for a number and prints all the numbers from one up to that number. 19 00:02:04,700 --> 00:02:07,370 So he does that using something called a loop. 20 00:02:08,600 --> 00:02:09,880 So let's take a look. 21 00:02:09,940 --> 00:02:10,350 Adequate 22 00:02:14,220 --> 00:02:24,630 over here we declare three strings the first string enter num is to prompt the user to enter a number 23 00:02:25,410 --> 00:02:26,850 which is the string here 24 00:02:37,540 --> 00:02:49,480 then the second string is to put the message which is the number is 1 2 entry so the format he's using 25 00:02:49,480 --> 00:02:51,200 presentation D. 26 00:02:51,460 --> 00:03:02,870 Now if I may specify a we'll be replacing the integer descends four digit which means integer then a 27 00:03:02,870 --> 00:03:12,590 priest uh garish return character and a line character which together is known as the new line character 28 00:03:14,360 --> 00:03:23,030 it prints in your own character so that he will go to the next line after printing the number and then 29 00:03:23,030 --> 00:03:27,990 the last is counter which we don't use. 30 00:03:28,040 --> 00:03:30,480 So you can actually it in this evil in this 31 00:03:34,580 --> 00:03:50,150 next movie be for more strings under the OBSS section and first do not strings are used by the windows 32 00:03:50,180 --> 00:03:55,200 api input handle and battery right away. 33 00:03:57,190 --> 00:04:06,040 The next number variable is used to store the number after it has been converted from string number 34 00:04:07,780 --> 00:04:10,810 in both string is used. 35 00:04:11,080 --> 00:04:12,220 Input from the user. 36 00:04:13,240 --> 00:04:19,990 So if these enter history you would be stored in interesting and then subsequently converted into a 37 00:04:19,990 --> 00:04:23,090 number and start next number. 38 00:04:27,640 --> 00:04:36,620 When the program starts it will print the on screen to show this enter a number a message and then answering 39 00:04:36,760 --> 00:04:39,820 comes from here. 40 00:04:40,120 --> 00:04:43,360 Then you will get the input handle. 41 00:04:43,660 --> 00:04:46,990 We should be quiet for the next function. 42 00:04:47,030 --> 00:04:54,630 Refer refile and then write the input typed in by the user. 43 00:04:54,630 --> 00:04:57,870 So the user types tree tree will be stored. 44 00:04:57,920 --> 00:04:58,830 He input string 45 00:05:02,480 --> 00:05:03,630 then the next function. 46 00:05:03,640 --> 00:05:17,450 String 2 unsigned long will convert the input string into a number in base 10 and store in he s register. 47 00:05:17,530 --> 00:05:24,760 And this line most on that number into the next number variable which is the effect here. 48 00:05:28,730 --> 00:05:40,650 Then here is where the loop starts and the loop and in order to do a loop here we need at least two 49 00:05:40,650 --> 00:05:42,020 things. 50 00:05:42,240 --> 00:05:48,290 First is a counter to count how many times you are looking. 51 00:05:48,580 --> 00:05:55,990 We use easy X and assign it the initial value of 0. 52 00:05:57,370 --> 00:06:07,400 And we also need to have another register to print the current number 1 2 3 and we also initialize it. 53 00:06:07,570 --> 00:06:12,450 0 name we have a label. 54 00:06:12,570 --> 00:06:18,260 This is this time on the actual look and this label is referred to here. 55 00:06:21,120 --> 00:06:23,740 Serving the instructions finish. 56 00:06:23,850 --> 00:06:27,530 We jump back to the label over and over again. 57 00:06:29,250 --> 00:06:39,560 In a loop so each time he jumps up you increment the counter and then check whether they come day has 58 00:06:39,570 --> 00:06:41,120 exceeded the max number. 59 00:06:42,570 --> 00:06:54,880 The next number remember in this case will be three and initially 6 will be 0 and then increment 1 and 60 00:06:54,880 --> 00:07:06,760 then compare to the max number so when you compare like this ICAC is one case number history so here 61 00:07:06,760 --> 00:07:10,870 we are checking area hit the next number. 62 00:07:11,310 --> 00:07:17,420 If we have not exceeded the max number then it will not jump. 63 00:07:18,850 --> 00:07:23,420 Jamie's jump above that means jump above. 64 00:07:23,560 --> 00:07:27,620 If it succeeds bigger than nice number. 65 00:07:27,620 --> 00:07:36,800 So Jamie is to check whether the sea is bigger than the next number you say is not bigger than the mass 66 00:07:36,800 --> 00:07:38,100 number. 67 00:07:38,350 --> 00:07:39,890 This will not change. 68 00:07:41,180 --> 00:07:47,810 But you see if you see it is bigger than a mass number then it will jump to this label. 69 00:07:47,990 --> 00:07:53,720 I see program now here and that will create a loop. 70 00:07:53,800 --> 00:08:01,450 So it is how we keep track of how many times we are looping each time we look back to the top. 71 00:08:01,450 --> 00:08:06,180 You increment a section by 1 so eventually easier. 72 00:08:06,240 --> 00:08:09,000 So we can be your name my number. 73 00:08:09,240 --> 00:08:12,280 And that is when he will jump out the loop 74 00:08:15,400 --> 00:08:18,340 if in this case is x is 1. 75 00:08:18,570 --> 00:08:28,700 He will not jump but said you increment EDI X so easily X initially is initialized to 0 when you increment. 76 00:08:28,860 --> 00:08:41,740 Yes my 1 it becomes 1 and next thing you want to do is to print so all this is to print this he the 77 00:08:41,750 --> 00:08:42,290 x value 78 00:08:46,110 --> 00:08:54,990 by before you print you need to save here for this this is why are doing this to why do we need to save 79 00:08:54,990 --> 00:08:56,420 these two registers. 80 00:08:56,920 --> 00:09:04,870 Because when you call any function the function meaning you stop the registers and corrupt the values 81 00:09:04,900 --> 00:09:06,610 in them. 82 00:09:06,610 --> 00:09:10,670 So it is important for you is to use to excess. 83 00:09:11,140 --> 00:09:14,580 And it has to register in the main function. 84 00:09:14,640 --> 00:09:22,230 Now make sure you save a copy first before you call the print function or any other function. 85 00:09:22,390 --> 00:09:30,100 So that is why you are saving these two registers values starting this register as so we push this through 86 00:09:30,250 --> 00:09:38,120 the stack in order to save he registers can we call the function after the function is called we put 87 00:09:38,250 --> 00:09:43,940 back the safe values back to the registers. 88 00:09:43,960 --> 00:09:52,810 So this too is used in conjunction with just to this too is the saved register is too easy. 89 00:09:52,810 --> 00:10:00,220 Put back the original value in those registers and the order of call is opposite. 90 00:10:01,180 --> 00:10:10,960 So if you push these six first followed by ADX when you pop you should pop PDX was followed by six. 91 00:10:11,730 --> 00:10:19,970 So after you see if you registers then he will making a call to the print function so this pushing this 92 00:10:19,970 --> 00:10:24,170 year he says set up the barometer for the print function. 93 00:10:24,400 --> 00:10:32,720 This year started before Silvia gonna push the index value which is 1 and then you're going to print 94 00:10:32,720 --> 00:10:41,210 it so the pin if you print the output message the first barometer and substitute index inside it. 95 00:10:42,320 --> 00:10:44,960 So what do you get a score here. 96 00:10:45,380 --> 00:10:54,380 Our full message contains the percentage V for my specify a which should be replaced by Edi X the second 97 00:10:54,380 --> 00:10:54,990 pyramid. 98 00:10:56,270 --> 00:10:57,440 Yes. 99 00:10:57,440 --> 00:11:02,500 So you will print one and then you will go to a new right. 100 00:11:02,690 --> 00:11:10,490 Because at the end of this is the new line correctness. 101 00:11:11,410 --> 00:11:19,890 Thereafter you will pop back the original values in the easy X and yes it just is and then jump back 102 00:11:20,220 --> 00:11:24,770 to and holding repeating in. 103 00:11:24,870 --> 00:11:34,800 So eventually yes you become larger than max number and Jan will take place and he will see too. 104 00:11:35,220 --> 00:11:41,910 So you will jump out of the loop and end the program here. 105 00:11:41,910 --> 00:11:44,360 So this is how it works. 106 00:11:44,370 --> 00:11:53,130 So basically you have a counter you need to have a counter counter is important and you need to incriminate 107 00:11:53,130 --> 00:12:01,710 counter and check the counter so that you can see the look when a condition for a sitting is become 108 00:12:02,580 --> 00:12:03,210 satisfied. 109 00:12:04,560 --> 00:12:07,060 So that's all for this lesson. 110 00:12:07,260 --> 00:12:11,590 Try to modify this to do other things. 111 00:12:11,640 --> 00:12:14,160 We will look at it as an exercise. 112 00:12:14,160 --> 00:12:15,780 So thank you for watching. 113 00:12:15,790 --> 00:12:17,020 I'll see you in the next hour on.