Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How does the EEOC define sexual harassment?

Answered: 1 week ago