Question
Implement a program to find the average of 100 integers that are randomly generated, using both C and RISC-V assembly, and simulate the assembly program
Implement a program to find the average of 100 integers that are randomly generated, using both C and RISC-V assembly, and simulate the assembly program execution using RARS. 3 a. The C program MUST follow these steps: 1) declare an int array of 100 elements, and use a for loop to generate 100 integers and store them in the array; 2) use another for loop to accumulate those numbers by reading them from the array and adding up to a variable; 3) calculate the average by dividing the accumulated sum with 100, and 3) print the average and return the average. Your program should NOT do the number generation and accumulation in one loop. Write C program from https://repl.it/languages/c. The functions for generating random numbers can be found from Lab 03 1-D stencil code. b. Converting the C program to RISC-V assembly and simulate its execution using RARS. To use array in assembly code, your code needs to reserve space in the data section. Check the memory.s file in RARS repo (https://github.com/TheThirdOne/rars/blob/master/test/memory.s) for using .space to reserve memory for an array identified by a symbol, and how to use la instruction to load the memory address (first element of the array) to a register
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started