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

Consider the following code segment: LD R1, 0(R2) SUB R4, R1, R5 AND R6, R1, R4

ID: 3783464 • Letter: C

Question

Consider the following code segment: LD R1, 0(R2) SUB R4, R1, R5 AND R6, R1, R4 OR R8, R4, R6 a. List all potential dependencies & data hazards that exist (for our 5 stage pipeline). Remember that a dependency may exist that is not a hazard on your particular pipeline. b. Assume that your CPU cannot forward. Without changing the order of instructions show how the minimal number of NOPS can be inserted between the instructions to eliminate the harzards. c. Assume that your CPU can forward. Now show the minimal number of NOPS that must be inserted to eliminate the hazards.

Explanation / Answer

Answer

a. Potential dependencies are between LD-SUB, SUB-AND and AND-OR.

b.
LD R1,0(R2)
nop
nop
SUB R4, R1, R5
nop
nop
AND R6, R1, R4
nop
nop
OR R8, R4, R6

So without forwarding 6 nops are needed

c.
LD R1,0(R2)
nop
SUB R4, R1, R5
nop
AND R6, R1, R4
nop
OR R8, R4, R6

So, with forwarding 3 nops are needed.

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