Question: You are given two 10 element signed integer arrays (A and B). Array A starts at base address 0x190 and array B starts at base

You are given two 10 element signed integer arrays (A and B). Array A starts at base address 0x190 and array B starts at base address 0x1C0. Use x2 (SP) as the stack pointer for your stack frame. The stack should start at address 0x3E8 and grow down in data memory (0x3E8, 0x3E4, 0x3E0 ...). Assume each of these arrays could have the value zero so DO NOT rely on zero as a null terminator. Use recursion to calculate the sum of the positive elements in the two arrays. Store the result into register x10. Note, recursion requires you to implement stack frames and to recursively solve problems. Solutions done iteratively with not be accepted.

You are given two 10 element signed integer arrays (A and B).

i was able to write the code in C++ please put in assemble risc-v format

#include using namespace std; Dint sumTwo(int A[], int B[], int size) { int tempA = 0; int tempB = 0; int tempSum = 0; if (size == 0) return 0; else { if(A[size-1] > 0) tempA = A[size-1]; else tempA = 0; if(B[size-1] > 0) tempB = B[size-1]; else tempB = 0; tempSum = tempA + tempB; return sumTwo(A, B, size: size-1) + temp Sum; } } Jint main() { int A[10] = {1,2,-3,4,12,323,-1,132,95,66}; int B[10] = {0,1,0,2,0,3,4,5,6,7}; int result = sumTwo(A, B, size: 10); cout

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!