As we approach the final lecture of this section, we encounter the assembly language instruction j
p jump if below or equal.
An essential command that guides the path of programs execution based on a particular comparison condition.
In this section, you have been gradually building a foundation of understanding for assembler language,
and the JB instruction is another stepping stone in this journey.
Understanding its role and significance will serve as a bridge as you transition to the next section
where we will harness the knowledge gained here to craft more advanced and sophisticated assembler programs.
Imagine you are reading a book and instruction is like a crossroads in the story, a point where the
plot takes a different direction depending on certain condition.
Similarly, in assembly language programming, the JB jump if below or equal instruction serves as a
decision making tool.
Now here is how it operates.
Comparing results or comparing values.
So just like comparing two cups of water to see, which has more, the J.B. instruction compares two
values.
These values could be numbers stored in different places in your computer's memory.
Making a decision.
The instruction then helps your computer decide what to do next.
If the first value is less than or equal to the second value.
The JB instruction tells the computer to take a different path.
A jump.
Jump or continue if the condition is met.
Your program jumps to a new section of the code.
Like turning to a different chapter in a book.
If the condition isn't met, the program just keeps going in order, like reading throughout the book
page by page.
As we conclude this section with GBA instruction, remember that you have learned here sets the stage
for what's coming next.
Next.
And in the upcoming section, you will take the knowledge you have gained and use it to create more
intricate and sophisticated assembly programs.
Just as books final chapters prepares you for the sequel, your understanding of GBC paves the way for
the exciting challenges and achievements that await you in your assembly programming journey.
Now let's, as we always do, let's create some code and understand our deeper way.
Let's firstly get started by writing section.
Here.
Uh, section data are value one db 15 value two DB 20.
So we are allocating in.
Here we are allocate memory for value one and initialize it with 15.
And here we are doing the same, but we are initializing it with 20.
Now we are going to section text.
Text and global start.
And in the start here we will load the value stored at memory address value one into al.
Value one and we will load the value stored at memory address value two into pl move.
PL.
Value to.
And here we will compare the value in A and B with this p, a, l, p, l, and after that we will use
this j p.
E.
J.
B.
J.
B below.
Or.
Equal.
And here we are.
Uh, we are performing a comparison between the values in A, L and b, l, and here we are.
Jump.
We are telling the assembly to jump to below or equal if l is below or equal to b l, and after that
we will write not below or equal label.
And here you will insert in insert your code here, put here to code here and in this case.
So in this case, this means that value one is not below or equal to value.
Two value one is not below or equal or equal to value to value two And we will also create this below
or equal label.
Below or equal label where our condition is met.
So insert your code here.
So let's fix that your code here.
So if we.
If you make this like change the value to 2020 here because it also it will be more logical for this
example.
But yes, we can also do 15 or 20 so we can do whatever value we want.
Your code here.
So where value one is below or equal to value two.
And that's it.
So here we need to create this down here.
Here, we will insert our exit code.
Here in.
Insert your exit code here.
And now let's.
Explain this in more technical way here.
So in this data section, memory allocation, Memory.
Memory allocation is dedicated to value one which which here which value one is initialized with 20
and here we in value two we are doing the same, which is similarly memory is allocated for value two
and initialized to.
20 as well.
And after that.
Uh, in this start, our process commences with the move instruction responsible for loading the byte
size value, uh, from memory location value one into the Al register.
And in parallel the Move instruction accomplishes the same loading the byte size value from memory location
value two into the Belle Register and here we the CMP instruction carries out a meticulous comparison
between the contents of Al and Belle registers.
And here the after that the JB The decision making aspect of our journey unfolds with the J.B., which
is jump if below or equal instruction.
It gets us to the below or equal label if a a al is below or equal to Belle.
And after that here for this segment provides you with the technical canvas to implement codes specifically
tailored to a scenarios where value one is not below or equal to value.
Two.
And here in below or equal label we have in the space.
Your technical prowess takes center stage allowing you to craft code addressing scenarios where value
has value.
One is indeed below or equal to value two and in done.
This is the conclusion of our journeys marked by the down label indicating the final stage of our program's
execution.
And as we navigate this assembly code, we navigate the intricate arrays of conditional branching and
comparisons encapsulating scenarios where value one is either below or equal to value.
Two.