Question: Find the control hazards in the following code segment, and show the hazards on a pipeline diagram: la $t0, ar2 lw $t1, size lw $t2,

Find the control hazards in the following code segment, and show the hazards on a pipeline diagram:

 la $t0, ar2
 lw $t1, size
 lw $t2, nrows
 lw $t3, ncols
 addi $t4, $t2, -1 # nrmax 
 addi $t5, $t3, -1 # ncmax 
 ori $t6, $0, 0 # initialize row index to 0
 lwc1 $f0, val
 mfc1 $s4, $0
rloop: mul $t9, $t6, $t3 # multiply rindex by ncols
 mul $t9, $t9, $t1 # multiply by size of one array element to get roffset
 ori $t7, $0, 0 # initialize column index to 0 
cloop: mul $s0, $t7, $t1 # multiply cindex by size to get coffset
 add $s1, $s0, $t9 # offset of ar2[rindex][cindex] = roffset + coffset
 add $t8, $s1, $t0 # address of ar2[rindex][cindex] = offset + base
 sw $s4, 0($t8) # store val in ar2[rindex][cindex]
 addi $t7, $t7, 1 # increment the column index 
 sub $s2, $t5, $t7 # nc = ncmax - cindex 
 bgez $s2, cloop # branch back to cloop if nc >= 0
 addi $t6, $t6, 1 # increment the row index 
 sub $s3, $t4, $t6 # nr = nrmax - rindex 
 bgez $s3, rloop # branch back to rloop if nr >= 0
 ori $v0, $0, 10 # reach here if row loop is done
 syscall # end of program!
 

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!