Question: Implement the following C code in RISC - V . int x [ 1 0 0 ] ; for ( int i = 0 ;

Implement the following C code in RISC-V.
int x[100];
for(int i =0; i <10; i++){
x[i]= i*i;
}
REQUIREMENTS:
1. The array x should be stored on the stack contiguously. Use the first 10 memory addresses.
2. While we dont have access to the multiplication instruction, it can be implemented with a loop thatadds i to itself i times. (So the code would contain a nested loop).
3. For full credit you must implement the code in RISC-V using a looping structure via branches or jumps. You cannot simply write the values directly to memory. For example, I should be able to alter two starting values (the initial value of i (0) and the final value (10) and get a different sequence of numbers in memory.

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!