Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following MIPS assembly program executing on a pipelined datapath w

ID: 3907062 • Letter: C

Question

Consider the following MIPS assembly program executing on a pipelined datapath with no hardware for hazard handling. Assume a branch penalty of 2 cycles.

Loop: add

sub $4, $5, $1

or $5, $6, $7

and $8, $9, $10

slt $11, $12, $5

beq $13, $14, Loop

add $15, $16, $17

a) Add as few NOPs as possible to this instruction sequence to ensure that hazards are eliminated and the code executes correctly. Do not reorder any instructions.

b) Now reorder the instructions to eliminate as many NOPs as possible without affecting the correctness of execution.

Explanation / Answer

With nop

Loop: add
sub $4, $5, $1
nop
or $5, $6, $7
and $8, $9, $10
slt $11, $12, $5
beq $13, $14, Loop
add $15, $16, $17

With reorder

Loop: add
sub $4, $5, $1
nop
or $5, $6, $7
and $8, $9, $10
slt $11, $12, $5
beq $13, $14, Loop
add $15, $16, $17

Reordering can not reduce the number of nops

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote