For some basic practice, unroll the following code three times, and reschedule it to avoid as many stalls as you can. One possible answer will be found off the 'Answers' link below.

Loop: LW R3, 0(R1) ; load in an array entry
     ADDI R4, R3, #50 ; add a constant
     MULT R4, R4, R4 ; square the new value
     SW R4, 600(R1) ; store the new value
     ADDI R1, R1, #4 ; increment pointer
     SUBI R5, R1, #300 ; check whether ended
     BNEZ R5, Loop ; branch

Essentially, this loop adds fifty to a word in an array, and squares that, then stores the result into another array. An answer.


Prev Next