Question
This is supposed to be written in the MIPS assembly language using the MARS simulator. All that needs to be done is an input should
This is supposed to be written in the MIPS assembly language using the MARS simulator.
All that needs to be done is an input should be picked to choose how many inputs the simulator will take until the correct number of even integers are available, and then the sum of the integers should result. Please keep it short and simple.
This is my code so far. Please don't make dramatic changes other than what is required. it should be a relatively short solution.
.data str1: .asciiz "How many even numbers would you like to add together? " str2: .asciiz "The sum of the numbers is " .text main: #print str1 li $v0, 4 la $a0, str1 syscall #Input how many even numbers want to be taken li $v0, 5 syscall add $t0, $0, $v0 loop: beq $s0, $t1, done li $v0, 5 syscall addi $t1, $t1, 1 li $v0, 5 syscall add $t1, $v0, $0 div $t1, $t0 mfhi $t2
done: #print str2 li $v0, 4 la $a0, str2 syscall exit: li $v0, 10 syscall
1. Write a program that asks the user to enter the number of even integers that needs to be added together. Then you use the loop to get the integers from user and add the even numbers together. Finally your program should output the sum on the screen Sample input and output could be: How many even numbers you like to add together? 5 4 6 10 The sum of the numbers is 30Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started