The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+29 votes

Delayed branching can help in the handling of control hazards

For all delayed conditional branch instructions, irrespective of whether the condition evaluates to true or false,

  1. The instruction following the conditional branch instruction in memory is executed

  2. The first instruction in the fall through path is executed

  3. The first instruction in the taken path is executed

  4. The branch takes longer to execute than any other instruction

asked in CO & Architecture by Veteran (59.5k points)
retagged by | 3.7k views

Suppose I4 occupy the delay slot isn't it going to change the behaviour of program, when R1 is equal to 0 then branch will be taken and  Store instruction (I4) will be skipped.

sequencing of program after I4 occupy delay slot will be.




BRANCH to Label if R1 == 0


That is the DELAYED BRANCH is all about. Even if the condition evaluates TRUE and branch is taken (I4) will still be evaluated because the instruction is already FETCHED in the pipeline and being a wanted instruction IT IS NOT FLUSHED OUT of pipeline unlike other instructions which are not used as delayed branch slot.

Ask if you still have doubt.
some more expln. ?

Link for second part of this question is -->

3 Answers

+35 votes
Best answer

76. Answer is A. In order to avoid the pipeline delay due to conditional branch instruction, a suitable instruction is placed below the conditional branch instruction such that the instruction will be executed irrespective of whether branch is taken or not and won't affect the program behaviour. 

77. Answer is D) I4. The STORE instruction can be moved below the conditional branch instruction. Whether the branch is taken or not, STORE will be executed as the next instruction after conditional branch instruction, due to delayed branching.

Here, I3 is not the answer because the branch conditional variable R1 is dependent on it. Same for I1. Similarly, I4 has a dependency on I2 and hence I2 must be executed before I4. 

answered by Veteran (352k points)
selected by
I couldn't understand the right side of tht protion.

I dnt evn knw wht beq n cr0 is.
in if we were doing != condition.

In assembly it became beq- branch on equal. So, NOT EQUAL became EQUAL here with a JUMP. The semantics of the code remains the same though the condition is reversed.
@Arjun, could you plz explain the difference between option(1) and option(2) ?
@arjun sir could you plz explain why option(b) is nt true ?
can we place instructions executed by true condition just after conditional branch instruction that is in taken path just  after conditional branch instruction.
I am not able to get any of the options. What i have read id that we exacute an instruction that would be anyways executed, independent of the branch condition .For eg in quest no. 77) , I4 would be anyways expected , so this is the instruction we execute after branch (not in order) to avoid branch penalty.

as for this question,
a) if we execute instruction following conditional branch, it would be same a snormal flow of thw program and may case branch penalty if branch condition evaluates to false

b) as per the suggested article, i ma not able to understand the concept of fall through path. in first case it says condition on evaluation of if as true as fall through  and its different for the other one.

c)  first instruction in taken path is same as option a)
d) its wrong because branching will take same time to execute

please help me clear the concept.
@aayushi plzz see my ans i think it ll definetly helps u and after that if u have any doubt then  can tell me.

fall through path depend on instruction.If condition is false it is in fall through path
But here question said, irrespective of condition is true or false
that is why A) is answer

See, it is called delayed conditional branch because it first execute instruction after the following that delayed branch and then condition is evaluated.Condition is evaluated lately, that is why it is called delayed branching


Example to Understand what is fall through path:-

Branch instructions divide the execution path in two paths, the target path and the fall-through path. The address of the first instruction on each path is referred to as target address and fall-through address

Here 102 is fall through address and 500 is target address(target address is the address we want to branch).

If the condition evaluates to true then we go to target address i.e 500 otherwise we go to fall through address

   101       JZ 500

   102       Next Instruction




 500     HLT

@arjun sir according to you -branch delay slot is a technique where we put an instruction which have no dependence on the branch condition to be executed just after the branch instruction.

so why I2 cannot be the ans as it is not dependent on the branch condition???

Plz clear my doubt.
que. 76.  but even if condition is true or false the next instruction after the condition will definitely going to be executed if iam right?? the first instruction of fall through path will execute??
+8 votes

reference pattrerson book "the hardware software interface" 3rd edition page no 382 

answered by Boss (12.3k points)
+1 vote
Correct ans for qus no 77 is b only ...becoz we can rearrange I2 nd I3 ...nd after rearranging the instructions I2 is getting one delay slot ... means I2 is delayed by one slot becoz of rearrangement..hence option b is correct
answered by (29 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

37,072 questions
44,646 answers
43,699 users