Question: MIPS assembly Modify the file solution.asm so that the program calculates the product of the elements of an array A , starting from the value
MIPS assembly
Modify the file solution.asm so that the program calculates the product of the elements of an array A starting from the value of index first and ending with the value of the parameter last. In C syntax, the function declaration looks like this:
int productint A int first, int last
You do not need to take into account that overflow can occur, but we assume that the product will be small enough to fit in bits. In the file data.asm, the sequence A and the parameters first and last are defined. This file is included in the code file. Modify the variables as needed to test different inputs. But note that you must not change variable names etc. for the automatic tests to work! You may also not print any additional text to the console.
The response should be returned in register $v If first last, set register $v to indicate that an error occurred, otherwise $v
Here is the data.asm code:
data
array: word # sequence
first: word # index fr startvalue
last: word # index fr endvalue
Here is the code for the solution.asm which will be modified in the assignment:
include "data.asm"
data
text
main:
jal product
j exit
product:
jr $ra # return
exit:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
