Question: You will develop RISC - V assembly language implementations of the following problem and print the results to ensure that both the C implementation and

You will develop RISC-V assembly language implementations of the following problem and print the results to ensure that both the C implementation and your RISC-V implementation compute the correct answer.
Your executables must be named as follows, and must be compiled with a Makefile
We will test your projects using autograder
Note that in all your programs below you must follow the RISC-V function calling conventions that we cover in class.
Your solutions must follow the logic and implement the same functions as given in the C code.
Remeber to remove the line # YOUR CODE HERE from the starter code.
rstr: Reverse a string
$ ./rstr a
C: a
Asm: a
$ ./rstr FooBar
C: raBooF
Asm: raBooF
$ ./rstr "CS315 Computer Architecture"
C: erutcetihcrA retupmoC 513SC
Asm: erutcetihcrA retupmoC 513SC
C code we must follow
#include
#include
void rstr_c(char *dst, char *src){
int src_len = strlen(src);
int i, j;
for (i =0, j = src_len -1; i < src_len; i++, j--){
dst[i]= src[j];
}
dst[src_len]='\0';
}
rstr_rec: Reverse a string recursively
$ ./rstr_rec a
C: a
Asm: a
$ ./rstr_rec FooBar
C: raBooF
Asm: raBooF
$ ./rstr_rec "CS315 Computer Architecture"
C: erutcetihcrA retupmoC 513SC
Asm: erutcetihcrA retupmoC 513SC
C code we need to follow
#include
#include
void rstr_rec_func_c(char *dst, int dst_idx, char *src, int src_idx){
if (src[src_idx]=='\0'){
dst[dst_idx]='\0';
return;
}
// Copy the current character from the end of src to the start of dst
dst[dst_idx]= src[src_idx];
rstr_rec_func_c(dst, dst_idx +1, src, src_idx -1);
}
void rstr_rec_c(char *dst, char *src){
int src_len = strlen(src);
rstr_rec_func_c(dst,0, src, src_len -1);
}

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!