Question
Write an MIPS program to compute three sums: 1 + 2 + 3 + 4 + ... + 99 + 100 # all values 1100
Write an MIPS program to compute three sums:
1 + 2 + 3 + 4 + ... + 99 + 100 # all values 1100 1 + 3 + 5 + 7 + ... + 97 + 99 # all odd values 1100 2 + 4 + 6 + 8 + ... + 98 + 100 # all even values 1100
Do this by using the blt macro (branch if less than).
Use a register (say $t0) for the sum of evens, a register (say $t1) for the sum of odds, and another (say $t2) for the sum of all numbers. Do this with only one counting loop. The loop body will contain the logic to add the count to the proper sums. Don't use division to check odd or even, it is not necessary. A bitwise instruction is enough. Stop the program with a syscall with 10 in $v0.
Step 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