Today we'll take a look at how to write if else statements in assembly
go ahead and download this new file from the resource section and visit India for some projects for
Folder 0 4 if else statement this is a then and zip it
and then delete these if and opened a new folder
open the if else and file 972.
All right.
So this is a sample of an in-house House program.
Let's run it.
See what he does.
Click run compile and the ever knew far he AC has changed directory to this whole clean copy.
Open your mind from the spacebar and paste the bar and enter to enter the new directory type idea to
check the contents of this territory and this is the file you want to run.
So the time I followed by that time again and then press enter.
So you are asked to enter a number so I enter six not five minutes into five
has run the program again.
Let's enter.
And it is you enter five.
So this program checks where you're at five on five.
So let's take a look.
Oh here we have the strings.
Three strings under the isolation.
Very display internal string to probably use it.
A number.
Then you have message one string to give out the message saying you entered Phi and then on a message
call a message to to show the message string not five and then oh here you have to you show variables
needed by Windows API.
And here is where we print the message.
Using a print function to print industry which is here and to a number
and then you get any input handle like before.
And then you read the input whatever input you enter you'll be safe in the industry.
Oh here
next you use the string to and saying long function to convert this input string into a number base
10 number and the result of that conversion is starting E X and then you go to the next but it is the
new but just adding up we compared the number in years to five.
So the CMB from 50 reset into zero.
So it does reflect a set.
It means that he sees you go to Phi so this one test whether the 0 effect set.
So every sentence means that yes is equal to five therefore he will jump to this label equal five.
And here you will move message one into yes I say this one he's
in that fight.
So we move the message one want to yes I because we want to show this message.
After that we move on to the output result label where really push the yes I push it stack and then
we can bring it to show their message so yes I is actually storing in message one so many copying it
we show you enter fi now let's come back to hear again let's save your wonderful game again and this
time we do not end the fight how we enter and a number six so six we start in a string and convert it
into a number by using string to unsigned long.
And that's number six.
We start in he acts.
And here you compare the to five again six escapes a fight this time your comparison will not only true
because he has six so in this case the jungler not taken and therefore he will move on to the next instruction
so in the next instruction he will move the message two into Yes I.
So this is actually the house but
so I just base here.
So this is a but if you execute if this part is not true.
So evil is good despite my movie message to 2 yes a message to ease the string not fight
so no once the has been assigned a not five string.
He would then jam to the output result label and then he would bring the message starting year site
which is the message string not five so the syntax or the structure of the IDF statement is like this
we have a comparison or a test or some subtraction or addition operation and then followed by and jumped
us so they dumb either be taken or not taken.
So it just comparison is produces the same one which is true by setting a zero flat to one then he really
jump Jamie's jump.
You can also reduce it which means the same thing.
If the test here fails then he went on Gem instead he will go to the else but so any else but here we
will execute and then he will jump to the help of his.
So we need to jump here because if we don't you will fall through and execute this line.
That is why the jump is necessary.
So this is the structure of a if else statement which you can use whenever you write a program that
needs to make some kind of decision.
So that's all for this lesson.
Thank you.
Harding.