Question: Consider the following MIPS code. Note that R 0 ( register 0 ) in the MIPS ISA always has a value of zero. Assume that

Consider the following MIPS code. Note that R0(register 0) in the MIPS ISA always has a value of
zero. Assume that the branch is the first instruction executing after a jump.
a) Convert the MIPS code into C:
b) How many branch miss-predictions occur during this code's execution, if we use an
always-taken predictor?
Explain you answer:Consider the following MIPS code. Note that R0(register 0) in the MIPS ISA always has a value of
zero. Assume that the branch is the first instruction executing after a jump.
0x110 li R2,0 # v=0
0x114 li R3,16 # Loop bound for LoopJ
0x118 li R4,0 # j=0
LoopJ:
0x11C beq R4,R3,EndLoopJ # Exit LoopJ if j==16
0x120 li R5,0 # k=0
LoopK:
0x124 beq R5,R3,EndLoopK # Exit LoopK if k==16
0x128 add R6,R5,R4 # k+i
0x12C andi R6,R6,3 # (k+j)%4
0x130 bne R6,R0,EndIf # Skip if (k+j)%4!=0
0x134 add R2,R2,R5 # v+=k
EndIf:
0x138 addi R5,R5,1 # k++
0x13C beq R0,R0,LoopK # Go back to LoopK
EndLoopK:
0x140 addi R4,R4,1 # j++
0x144 beq R0,R0,LoopJ # Go back to LoopJ
EndLoopJ:
a) Convert the MIPS code into C:
b) How many branch miss-predictions occur during this code's execution, if we use an
always-taken predictor? __________
Explain you answer
 Consider the following MIPS code. Note that R0(register 0) in the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!