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 product(int 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 32 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 $v0. If first > last, set register $v1=1 to indicate that an error occurred, otherwise $v1=0.
Here is the data.asm code:
.data
array: .word 743805910621 # sequence
first: .word 2 # index fr startvalue
last: .word 4 # 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:
MIPS assembly Modify the file solution.asm so

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!