Question: USING MIPS!!!! 1. Write a program that asks the user to enter the number of integers that needs to be added together. Then you use

USING MIPS!!!!

1. Write a program that asks the user to enter the number of integers that needs to be added together. Then you use the loop to get the integers check to see if they are even and add them together. Finally your program should output the sum on the screen.

Sample input and output could be: How many numbers you like to add together? 5

2

4

3

6

5

The sum of the even numbers is 12

This is what I have so far, don't really understand the loop part......

.data

# Fun With MIPS!!!!!!!

fun: .asciiz "\t\tLoop Exercise "

fun1: .asciiz "\t\t_____________ "

# Have user input 2 numbers to be calculated

userInput: .asciiz "How many numbers would you like to add together: "

# Calculated Results

sum: .asciiz " The sum of the even numbers is "

sum2: .asciiz " "

.text

main:

# Display Header Information

li $v0, 4

la $a0 str1

syscall

la $a0 str2

syscall

la $a0 str3

syscall

# Fun header

la $a0 fun

syscall

la $a0 fun1

syscall

# User input

la $a0 userInput

syscall

li $v0, 5

syscall

# Store $v0 to $t0

add $s0, $0, $v0

# Loop

loop: beq $s0, $0, sum

add $s0, $s0, -1

j loop

bne

# sum = $t3

# Sum

li $v0, 4

la $a0 sum

syscall

li $v0, 1

add $a0, $t3, $0

syscall

# Sum2

la $a0 sum2

syscall

# End program

li $v0, 10

syscall

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!