Question: Assembly language programming of the MIPS Exercise 3 Counting Loop ( Put result in $15.) Write a program that computes the sum: 1 + 2

Assembly language programming of the MIPS

Exercise 3 Counting Loop ( Put result in $15.)

Write a program that computes the sum:

1 + 2 + 3 + 4 + 5 + ... + 98 + 99 + 100 

Do this, as above, by using the j instruction to implement a non-ending loop. Before the loop, initialize a register to zero to contain the sum, initialize another register to one to be the counter, and another register to 10110. Inside the loop add the counter to the sum, increment the counter, and jump to the top of the loop.

However, now, at the top of the loop put in a beq instruction that branches out of the loop when the counter equals 10110. The target of the branch should be something like this:

exit: j exit # sponge for excess machine cycles sll $0,$0,0 

Now run the program by setting the value of the PC to 0x400000 (as usual) and entering 500 or so for the number of Multiple Steps (F11). Your program will not need so many steps, but that is OK. The excess steps will be used up repeatedly executing the statment labeled "exit".

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!