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

SHORT ANSWER: Given the following MIPS code: lw $s1, 0($s5) add $t0, $s1, $s2 be

ID: 3890380 • Letter: S

Question

SHORT ANSWER:

Given the following MIPS code:

                        lw         $s1, 0($s5)

                        add      $t0, $s1, $s2

                        beq      $t0, $t1, next

                        sub      $t2, $t1, $t0

                        addi     $t2, $t2, 1

                        j           after

            next:    sw       $s1, 20($t1)

            after:    sw       $t0, 0($s5)

Considering the above code, and a multi-cycle processor. In which cycle of the program run does the ALU add the values from registers $s1 and $s2? Assume the first instruction starts running in cycle 1.

Explanation / Answer

Answer

By the instructions given in the cycle 2 ALU adds the values from registers $s1 ans $s2 and then stores in $s2 registers as given instruction.

Thank You