Question: Write a MIPS assembly language program to solve the following problem. For a set of integers stored in an array , calculate the sum of

Write a MIPS assembly language program to solve the following problem.

For a set of integers stored in an array, calculate the sum of the positive numbers and the sum of the negative numbers. The program should store both counts in memory variables:posSum and negSum . Numbers should read from the array one at a time with a zero value (0) being used to signal the end of data (the zero value is acting as a "sentinel" value).

For examle, if your array has the values: 10^10 -5^10 -30^10 15^10 20^10 -1^10 -26^10 -18^10 0^10, then your program should update the posSum ans negSum variables to 45^10 and -80^10, respectively.

For example, your .data section for the array values: 10^10 -5^10 -30^10 15^10 20^10 -1^10 -26^10 -18^10 0^10, will be:

. data

array: .word 10,-5,-30,15,20,-1,-26,-18, 0

possum: .word 0

negsum .word0

.text .

.globl main:

# MIPS Assembly language program here

li $v0, 10 # system call to exit the program syscall

Before you start writing MIPS assembly language, write a high-level language algorithm. THEN, translate it to MIPS assembly language.

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!