Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

.link{ }

Answered: 1 week ago