Skip to content
Get App

L-1.12: Program Control Instructions(Types of Control Instructions) | Computer Organization

Gate Smashers explains Program Control (Transfer of Control) Instructions, covering sequential execution via the program counter, unconditional and conditional branches, jump, skip, and call/return.

Key Takeaways

  • Program control instructions alter the normal sequential flow by changing the program counter.
  • Branches are divided into unconditional (always taken) and conditional (taken only if a condition is met).
  • Call and return enable subroutines, and a stack is typically used to save the return address.

What the video covers

  • Introduces Program Control Instructions, also called Transfer of Control Instructions, as important in computer organization.
  • Explains that instructions normally execute sequentially, with the program counter pointing to the next address (implicit mode).
  • Describes how programmers need non-sequential execution, which program control instructions enable.
  • Uses a C program example: calling a function transfers control to the function's definition and then returns.
  • Covers unconditional branches, where the target address is given directly (e.g., jump 2000, branch 3000).
  • Explains skip, which bypasses the next instruction by advancing the program counter past it.
  • Explains call, which saves the return point and jumps to a subroutine, with return typically using a stack.
  • Covers conditional branches such as BE (branch if equal) and branch-if-non-zero, which jump only when a condition holds.
  • Notes that instruction set naming varies: skip may be unconditional or separate depending on the microprocessor.
  • Concludes by describing returning from a subroutine to continue normal execution after the call.

Answers

Questions about this video

What is the main purpose of program control instructions?

They allow the program to deviate from the normal sequential execution order by changing the program counter to a different address. This enables programmers to jump to other code, such as functions defined elsewhere.

How does a conditional branch differ from an unconditional branch?

An unconditional branch always transfers control to the target address. A conditional branch, such as BE, first checks a condition (for example, whether two register values are equal) and branches only if the condition is true, otherwise continuing sequentially.

What does the skip instruction do?

Skip causes the program counter to bypass the next instruction, so the instruction after the skipped one is executed. According to the video, if I3 is a skip, I4 is not executed.

Full Transcript — Download SRT & Markdown

00:00
Speaker A
Hello friends, welcome to Gate Smashers In today's video we are going to discuss Program Control Instructions or we call them Transfer of Control Instructions Program Control Instructions are very important in Type of Instruction And we use maximum time in all the concepts of computer organization
00:20
Speaker A
Type of Control Instruction or which you can call Program Control Instruction They have a very important advantage And that is generally we execute our instructions in sequential order Like if we talk, we have multiple instructions in our memory
00:39
Speaker A
And what we do with those instructions We execute those instructions one by one And program counter helps in this So in program counter by default Let's say if it is 100, 101, 102, 103 So program counter by default address 101 is the address in program counter
00:58
Speaker A
Means whatever instruction, whatever memory location it is on What will happen on that program counter Program counter contains that address Now as soon as we fetched the instruction i1 Along with that program counter is on 102 Then when we access i2 means we will fetch it to execute
01:17
Speaker A
Then it will come on 103 means on i3 Then when we execute i3 then it will come on 104 That is what i4 is on Means we are executing in sequential order And this mode is called implicit mode
01:31
Speaker A
When we execute program counter in implicit mode Then we execute one by one in sequential order But if we talk about programming Programmer should have this facility That it is not necessary that it should run in sequential order every time
01:47
Speaker A
It can also work out of the order It can also work randomly on any address So program control instruction or transfer of control instruction helps in that For example if we see from a simple example In main program, let's say in C program
02:03
Speaker A
If we call any function in the main program Let's say I called function f1 Now I am invoking f1 here But f1 can be defined here F1 here, its definition should be read Then what I am doing is
02:19
Speaker A
Let's say I am calling f2 And f2's definition can be Its definition should be read somewhere else So obviously if I call f1 Then what does it mean to call f1 When I execute this instruction Then after executing this
02:34
Speaker A
My next instruction will not execute It will go on f1 Means the control will go from here to this location So whenever we work on this type That comes in program control instruction And especially if we talk about it
02:51
Speaker A
The main instructions that come Those instructions are branch instruction Branch instruction also comes in two types Unconditional and conditional branch Unconditional branch means Where my target address is Target address means Like in sequential order Target address obviously I know
03:12
Speaker A
First 101, 102, 103, 104 If every instruction is of 1 byte If you take 2, 2 or 4 bytes of instruction Then according to that It will keep increasing one by one But whenever we branch Or subroutine or call by value
03:28
Speaker A
Whenever we execute this type of instructions Then there my program counter address When we find out that target address Then it generates a new address So in branch unconditional means Where my target address is given Means like if I write jump
03:48
Speaker A
Jump 2000 What does this mean That if you are executing normal If you know that jump 2000 Means what you do to program counter value Change it to 2000 Because you don't have to execute normal You have to jump at 2000 location
04:09
Speaker A
Similarly if we talk Let's say I also write general branch Branch 3000 location So what does this mean That you have to go to that particular address Means your target address That is now this Value it in program counter 3000
04:24
Speaker A
And execute the instruction that is there Similarly if we can use here Skip Or generally we use it SKP What is the meaning of skip Let's say if I am executing the instruction Normally 100 is written on 101, 102
04:44
Speaker A
I1, I2, I3 If I am executing like this Let's say program counter is at 100 location I fetched I1 and it went to 101 I fetched I2 and it went to 102 Now let's say I3 Means who is written on 102
05:03
Speaker A
And if I3 instruction is my skip What does this mean That program counter is denoting to 102 What is 102, I3 As soon as I fetched I3 It is coming to 103 Means it is pointing out on I4
05:21
Speaker A
But when we executed I3 When we decoded it Then I got to know that this is skip And what is the meaning of skip That you skip one address Means the next instruction was I4 You don't have to execute that
05:37
Speaker A
Means what is next Let's say it is written on 104 So you will take program counter which is on 103 What will you do You will take it on 104 Means this execution will not happen Means you will not execute I4
05:52
Speaker A
So whatever comes of this type In which we do not check any condition We directly jump or skip Or we directly branch Let's say if we talk about call Like we use call and return in subroutine So what is the meaning of call
06:08
Speaker A
Let's say call 3000 So what is the meaning of call 3000 You are normally executing instructions one by one If some instruction comes Let's say I4 is there And when you fetched I5 As soon as you fetched Program counter went to 105
06:27
Speaker A
Means it went to the next instruction And when you decoded I5 Then you found out that this is call And what address is 3000 in call Means your target address is 3000 You don't have to execute this instruction 105
06:45
Speaker A
Go directly to 3000 So whatever function is there on 3000 address Whatever instruction is there You have to execute it So in which comes this type of instructions Branch And if we talk about it Unconditional branches Next comes our conditional branches
07:03
Speaker A
In conditional branches Where we check condition Like this is the concept But we have to check some condition Like if we talk about BE That is Branch Equal Means if your value is equal Then you have to branch
07:18
Speaker A
Like if I use BE R1 R2 2000 Let's say if I write this instruction So what does it mean That you pick up the value of R1 and R2 register If R1 value and R2 value is equal If these two are equal
07:36
Speaker A
Branch if equal Means if these two values are equal Whatever is in R1 and R2 register If it is equal Then you branch Means you jump on kind of 2000 address Means what is your target address 2000 But if the value of R1 and R2 is not equal
07:57
Speaker A
Obviously let's say its value is 0 Its value is 1 If it is not equal Then what you do in that case Don't do anything You execute the next instruction Means if your I6 is I6 or I7 If this instruction comes out
08:13
Speaker A
If this value is equal Then you jump on 2000 address If it is not equal Then there is no problem Then in that case Whatever you are executing You keep executing it normally In this way branch not equal
08:28
Speaker A
Means if I talk Branch if not 0 Let's say B and Z That is branch if non-zero Let's say if I take value R1 2000 Means if R1 value That if R1 value is equal to 0 What is the question
08:46
Speaker A
What is the instruction Branch if non-zero But R1 value is 0 So if R1 value is 0 Then 0 is equal to 0 In this case you don't have to do anything Means you check a condition Like we check in if else
09:00
Speaker A
If this is true Then do this Else do this So we are doing the same thing here So whenever we branch What we do in condition We check some particular condition On the basis of that condition We jump on some address
09:15
Speaker A
If it is successful If it is unsuccessful Then we run normal execution ourselves And similarly if we talk about unconditional In that we go to the direct target address So these multiple instructions branches are main Sometimes you can be given
09:30
Speaker A
Skip or jump in the book separately It depends on different microprocessor On different instruction set Sometimes what happens In some instruction set Skip comes in unconditional But sometimes it comes separately So on an average you can say In branch instruction
09:47
Speaker A
You have unconditional Conditional branches Jump is there Branch is there Skip is there Call and return is there And specially in call and return We use stacks generally So that when we return What does return mean?
10:01
Speaker A
When we are calling 3000 Then what are we doing? We are jumping on some new address When we jump on this new address We will execute it After executing you have to come back Like we talk about this
10:16
Speaker A
You called F1 in the main function Now you went to F1 Now whatever was written in F1 You have to printf hello and done So now you will come back to this point So that you continue with next normal execution
10:28
Speaker A
So we use this call, return, skip, branch, jump Or whatever is conditional It comes in multiple Which we will see in the next video But here I am telling you a simple overview Which are the instructions Which come specially
10:44
Speaker A
in program control Or in transfer of control instructions Thank you.
Topics:program control instructionstransfer of controlprogram counterbranch instructionconditional branchunconditional branchsubroutine callcomputer organizationGATE examinstruction set

Get More with the SozAI App

Transcribe recordings, audio files, and YouTube videos — with AI summaries and speaker detection. 30 minutes free.

Or transcribe another YouTube video here →