Hello.
Today we are going to look at looks so download this file in 0 5.
Looks easy from the resource section for this lesson and place it in the far Sims projects folder thereafter
and zip it.
You may know the league is a far and open the new for the 0 05 looks
let's open the looks here so far and let's run it to see what he does.
Keep on run compile and now you have a new ESEA file so are going to go to this folder.
So yes copy this tough
and open your combine from type CV and frankly and paste the path presenter idea to list the content
and you should see a look start ESEA file.
Now let's run it
presenter.
Now enter a number let's say 3.
PRESENTER Any prints 1 2 3.
Let's try it again.
Let's enter 10.
PRESENTER Any prints 1 to 10.
So this program asks for a number and prints all the numbers from one up to that number.
So he does that using something called a loop.
So let's take a look.
Adequate
over here we declare three strings the first string enter num is to prompt the user to enter a number
which is the string here
then the second string is to put the message which is the number is 1 2 entry so the format he's using
presentation D.
Now if I may specify a we'll be replacing the integer descends four digit which means integer then a
priest uh garish return character and a line character which together is known as the new line character
it prints in your own character so that he will go to the next line after printing the number and then
the last is counter which we don't use.
So you can actually it in this evil in this
next movie be for more strings under the OBSS section and first do not strings are used by the windows
api input handle and battery right away.
The next number variable is used to store the number after it has been converted from string number
in both string is used.
Input from the user.
So if these enter history you would be stored in interesting and then subsequently converted into a
number and start next number.
When the program starts it will print the on screen to show this enter a number a message and then answering
comes from here.
Then you will get the input handle.
We should be quiet for the next function.
Refer refile and then write the input typed in by the user.
So the user types tree tree will be stored.
He input string
then the next function.
String 2 unsigned long will convert the input string into a number in base 10 and store in he s register.
And this line most on that number into the next number variable which is the effect here.
Then here is where the loop starts and the loop and in order to do a loop here we need at least two
things.
First is a counter to count how many times you are looking.
We use easy X and assign it the initial value of 0.
And we also need to have another register to print the current number 1 2 3 and we also initialize it.
0 name we have a label.
This is this time on the actual look and this label is referred to here.
Serving the instructions finish.
We jump back to the label over and over again.
In a loop so each time he jumps up you increment the counter and then check whether they come day has
exceeded the max number.
The next number remember in this case will be three and initially 6 will be 0 and then increment 1 and
then compare to the max number so when you compare like this ICAC is one case number history so here
we are checking area hit the next number.
If we have not exceeded the max number then it will not jump.
Jamie's jump above that means jump above.
If it succeeds bigger than nice number.
So Jamie is to check whether the sea is bigger than the next number you say is not bigger than the mass
number.
This will not change.
But you see if you see it is bigger than a mass number then it will jump to this label.
I see program now here and that will create a loop.
So it is how we keep track of how many times we are looping each time we look back to the top.
You increment a section by 1 so eventually easier.
So we can be your name my number.
And that is when he will jump out the loop
if in this case is x is 1.
He will not jump but said you increment EDI X so easily X initially is initialized to 0 when you increment.
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
x value
by before you print you need to save here for this this is why are doing this to why do we need to save
these two registers.
Because when you call any function the function meaning you stop the registers and corrupt the values
in them.
So it is important for you is to use to excess.
And it has to register in the main function.
Now make sure you save a copy first before you call the print function or any other function.
So that is why you are saving these two registers values starting this register as so we push this through
the stack in order to save he registers can we call the function after the function is called we put
back the safe values back to the registers.
So this too is used in conjunction with just to this too is the saved register is too easy.
Put back the original value in those registers and the order of call is opposite.
So if you push these six first followed by ADX when you pop you should pop PDX was followed by six.
So after you see if you registers then he will making a call to the print function so this pushing this
year he says set up the barometer for the print function.
This year started before Silvia gonna push the index value which is 1 and then you're going to print
it so the pin if you print the output message the first barometer and substitute index inside it.
So what do you get a score here.
Our full message contains the percentage V for my specify a which should be replaced by Edi X the second
pyramid.
Yes.
So you will print one and then you will go to a new right.
Because at the end of this is the new line correctness.
Thereafter you will pop back the original values in the easy X and yes it just is and then jump back
to and holding repeating in.
So eventually yes you become larger than max number and Jan will take place and he will see too.
So you will jump out of the loop and end the program here.
So this is how it works.
So basically you have a counter you need to have a counter counter is important and you need to incriminate
counter and check the counter so that you can see the look when a condition for a sitting is become
satisfied.
So that's all for this lesson.
Try to modify this to do other things.
We will look at it as an exercise.
So thank you for watching.
I'll see you in the next hour on.