Hello, my name is Typhoon, and in this lecture you will learn about the jump if greater.
So continuing our exploration, we arrive at a doorstep of G.
G.
This is a cryptic command denoting jump if greater.
So this particular instruction orchestrates a sophisticated dance involving the sign flag.
This the SF?
This is the.
Sign flag.
Uh, the over flag and the zero flag also.
So they are combined Symphony orchestra is to result in zero signifies a clear message.
The result is not less than or equal to.
So with a G we find ourselves embarking on an expedition through Sindh comparisons skillfully handling
situations where one value genuinely surpasses another.
So.
As I said, we are involving here sign flag, the overflow flag and zero flag as well.
And here we will create another example of our coding example here, just with just like we did in previous
lectures.
So we will create a section data fastly.
The we will create define a byte with a value of 30 while value one db 30 here value two db.
20, we are defining another byte with a value of 20.
And here we will write our text here.
Global.
And here we will write a start here.
Move.
Al.
Bite.
Value of one.
Here we are moving the value of, um, value of value one into the al register.
And.
And here, move dl.
Fight.
White.
Value two.
And here we are moving the value of value two into the B register.
And now we are comparing the values in A and B In order to do that, we will use the CMP, L and L,
and after that we will use the G here, G.
Here and name the label.
Big greater.
So here we are.
Jump.
We are telling the assembly code that jump two reader.
Reader label.
If a L is greater than b l.
So if it's not great, we will also write this label here.
So not.
Sir.
So this case, you will write your code here, your code here for not reader case.
And as well we will jump.
GMP, GMP done here.
So we are giving the jump to the done label in this case.
So if it's not greater, you need to jump to the done label.
But first let's actually write the greater label.
So reader, this case the we are your code here for reader case and we will also need to write a done
here since we are jumping to the done label here.
So we are obligated to write it.
So here we are At first we are exit.
And it will move racks fixed.
As you already know, we use it almost 100 times.
This is a fiscal number for exit and X or D.
This is the exit status zero.
And after that, we will call the Cisco.
That's it.
Here.
I will explain this again from the start here.
So in data section we here, we have two values are defined value one and value two the value value
one is defined as a byte with the value of 30 and value two is defined as a byte with the value of 20.
And we have the text section here.
This text section contains the actual code of the program, as you know here.
So the Start label is the entry point of the program and we also have the loading values here.
This move instructions.
The move Al byte value one instruction loads the value of value one into the Al register.
It uses the byte keyword to indicate that only a single byte is being loaded.
And similarly the byte value two loads, the loads, the value of value two into the Belle Register
as well.
And again, we are using this byte keyword to indicate that only a single byte is being loaded.
And here we also have CMP instruction.
This the CMP ILB instruction compares the values in the A, L and b l register, and this comparison
sets various flags, including the ZF0 flag, which indicates whether the two values are equal.
And here we also have the conditional jump here.
This.
Uh, g g g g instruction.
So this, uh, g greeter instruction checks the result of the comparison.
And if the Z is F is not set because a g f is greater than b, L, it jumps to the greeter label.
Otherwise it falls through to not greeter label.
And we have the labels here, uh, this greeter greeter and not greeter.
So the greeter label is where you can write code that executes when value one.
Is greater than value two and the not greater label is for writing code that executes when value one
is not greater than value two.
So the value two is greater than value one.
And at the end of it we have this done label.
The program flow reaches the done label after executing the relevant code based on the comparison and
we have mov rax 60.
This instruction sets the syscall number for the exit system call.
We have X or die or die.
This clears the die register as well as this is the exit status parameter and the syscall instruction
performs the exit syscall terminating the program.
So this code demonstrates this example of using conditional branching in assembly to execute different
code path paths based on the result of the comparison.
So that's it with our lecture, and I'm waiting you in the next lecture.