Question: How many RISC - V instructions does it take to implement the c code from exercise 2 . 2 5 ? If the variables a

How many RISC-V instructions does it take to implement the c code from exercise 2.25? If the variables a and b are initialized to 10 and 1 and all elements of D are intially 0, what is the t
20:04424
computer-organization-and-design-risc-v-edition-the-hardw.
Chapter_02-3
Chapter_02-2
computer-
T:
executed?
2.24.4[5]$2.7> For the loop written in RISC-V assembly above, replace the instruction "beq 6,0, DONE" with the instruction "b7t 6,0, DONE" and write the equivalent C code.
2.25[10]$2.7> Translate the following C code to RISC-V assembly code. Use a minimum number of instructions. Assume that the values of a,b,i, and j are in registers 5,6,7, and 29, respectively. Also, assume that register 10 holds the base address of the array D.
2.26[5]$2.7>CD2.27[5]$2.7>i5,6t addi x6,0,0
addi 29,0,100
LOOP: 1wx7,0(x10)
add 5,5,7
addi 10,10,4
addi 6,6,1
blt6,29, LOOP rojalt =0
29=100
x=MmanMMM[0]
x5 : it men Arrey [0]2.28[10]$2.7> Rewrite the loop from Exercise 2.27 to reduce the number of RISC-V instructions executed. Hint: Notice that variable i is used only for loop control.otal number of risc-v instructions executed to complete the loop?
How many RISC - V instructions does it take to

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 Programming Questions!