Question: For this assignment, you are to complete the implementation of a function which sums an array of numbers and returns the sum back to the



For this assignment, you are to complete the implementation of a function which sums an array of numbers and returns the sum back to the user. The function is to be called from a main program.
MIPS
comments in green is the "to-do"
# Procedure: sumarray # This procedure will surn the values in an array and return the sum of all of the numebrs added together. # Parameters: a0 This is a pointer to the start of the array that is to be printed al This is the number of numbers that are to be read in # Return Value: $v0 This will be the sum of all of the numbers sumArray: # start the prologue by moving the stack around and adding to the stack frame. addi sp, $sp,-64 sw Sra, 48 (Ssp) sw $SO, 44 (sp) sw s1, 40 (Ssp) sw $s2, 36 (sp) sw $S3, 32 (sp) sw $S4, 28 (sp) sw $S5, 24 (sp) sw $s6, 20 (Ssp) sw $s7, 16 (sp) sw a0, 12 (sp) sw $a2, 4 ($sp) s umArrayLoop: # Exit the loop If there are no more numbers to be summed based on the value in $a1 # Load $t0 with the number that is to be summed. # Add the value into the sum # Move the address by 4 bytes (1 word) # Decrease the count of remaining items to be summed by 1 j sumArrayLoop ends umArray: # Restore the stack to its initial status lw ra, 48 (sp) lw SSO, 44 (sp) lw $sl, 40 (sp) lw $S2, 36 (sp) lw $S3, 32 (sp) lw $S4, 28 (sp) lw $S5, 24 (sp) lw $s6, 20 (sp) lw $s7, 16 (sp) lw $a2, 4 (sp) lw $a3, 0 (sp) addi $sp, $sp, 64 Sra # Return from the procedure
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
