Question: Problem 5: For the following RISC-V assembly code fragments, what is the total number of RISC-V instructions executed? Translate the loops below to C
Problem 5: For the following RISC-V assembly code fragments, what is the total number of RISC-V instructions executed? Translate the loops below to C code. Assume that i is held in register t1, s2 holds result, and so holds the base address of the integer array A. If possible, modify the RISC-V code to reduce the number of RISC-V instructions executed. a. b. addi tl, zero, 100 LOOP: lw s1,0 (s0) add s2, s2, s1 addi s0,s0,4 addi tl, t1,-1 bne tl, zero, LOOP addi tl,s0,400 LOOP: lw s1,0 (s0) add s2, s2, sl lw s1,4 (s0) add s2, s2, s1 addi s0,s0,8 bne t1,s0, LOOP
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
