Question: Spring 2021 CDA3101 Programming Assignment 2 Date assigned: 2/8/21 Due date: 2/20/21 A 24-hour grace period with 20% penalty is given. No submission is accepted

 Spring 2021 CDA3101 Programming Assignment 2 Date assigned: 2/8/21 Due date:2/20/21 A 24-hour grace period with 20% penalty is given. No submission

Spring 2021 CDA3101 Programming Assignment 2 Date assigned: 2/8/21 Due date: 2/20/21 A 24-hour grace period with 20% penalty is given. No submission is accepted after the grace period. Instructions Transform the following code into RISC-V instructions. Your program should run correctly on the emulsiv simulator. Submit your assembly solution as a HEX File to Canvas before the deadline. You MUST verify that your submission in Canvas is successful and properly runs in the emulsiv simulator. Submissions after the due date for submitting the wrong file are not allowed so please upload the correct file. Multiple submissions are allowed, though only one will be graded (the most recent submission unless told otherwise). Problem (100 pts): You are given two 10 element signed integer arrays (A and B). Array A starts at base address Ox190 and array B starts at base address Ox1CO. 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. EXAMPLE C++ CODE BELOW int sum Two(int A[], int B[], int size) { int tempA = @; int temp = @; 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-1) + tempSum; int main(){ int A[10] = {1,2,-3,4,12,323,-1,132,95,66}; int B[18] = {0,1,0,2,0,3,4,5,6,7}; int result = sumTwo (A,B, 10); printf("%d ", result); return @; Spring 2021 CDA3101 Programming Assignment 2 Date assigned: 2/8/21 Due date: 2/20/21 A 24-hour grace period with 20% penalty is given. No submission is accepted after the grace period. Instructions Transform the following code into RISC-V instructions. Your program should run correctly on the emulsiv simulator. Submit your assembly solution as a HEX File to Canvas before the deadline. You MUST verify that your submission in Canvas is successful and properly runs in the emulsiv simulator. Submissions after the due date for submitting the wrong file are not allowed so please upload the correct file. Multiple submissions are allowed, though only one will be graded (the most recent submission unless told otherwise). Problem (100 pts): You are given two 10 element signed integer arrays (A and B). Array A starts at base address Ox190 and array B starts at base address Ox1CO. 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. EXAMPLE C++ CODE BELOW int sum Two(int A[], int B[], int size) { int tempA = @; int temp = @; 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-1) + tempSum; int main(){ int A[10] = {1,2,-3,4,12,323,-1,132,95,66}; int B[18] = {0,1,0,2,0,3,4,5,6,7}; int result = sumTwo (A,B, 10); printf("%d ", result); return @

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!