Question: Write a RISC - V assembly function to search for a specified integer in an integer array. The function should take the base address of

Write a RISC-V assembly function to search for a specified integer in an integer array. The function should take the base address of the array, the number of elements in the array, and the specified integer as function arguments. The function should return the index number of the first array entry that holds the specified value. If no array element is the specified value, it should return the value -1.(Basically, this is a linear search function). pseudo-instructions are not allowed except j target_label and jr ra.
```
int linear_search(int array[], int n, int x){
// Going through array sequencially|
for (int i =0; i n; i++)
if (array[i]== x)
return i;
return -1;
}
```
Write a RISC - V assembly function to search for

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!