Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The below assembly program adds up a list of n numbers, where the size n is stored in memory address N, and NUM1 denotes

The below assembly program adds up a list of n numbers, where the size n is stored in memory address N, and

The below assembly program adds up a list of n numbers, where the size n is stored in memory address N, and NUM1 denotes the memory address of the first number. Rewrite the program so that the numbers in the list are summed up in the "reverse" order: that is, the first number accessed is the last number in the list (i.e., NUMn), and the last number accessed is at memory location NUM1. Notes: . . . The numbers are stored in the memory of successive addresses. Nevertheless, only the memory address of the first number (i.e., NUM1) is given, while the memory address of the last number (i.e., NUMn) is unknown. If your program directly uses "addr NUMn" to represent the address of the last number, you will only receive partial credit. You have to offer concrete comments for all the parts you revise to receive full credit. You may use other common instructions (such as multiply/divide instructions) to ease the program revision. LABEL OPCODE Load Clear Move Load Add Add Subtract LOOP: Branch_if_[R2]>0 Store OPERAND R2, N R3 R4, addr NUM1 R5, (R4) R3, R3, R5 R4, R4, #4 R2, R2, #1 LOOP R3, SUM COMMENT Load the size of the list. Initialize sum to 9. Get address of the first number. Get the next number. Add this number to sum. Increment the pointer to the list. Decrement the counter. Branch back if not finished. Store the final sum.

Step by Step Solution

3.43 Rating (159 Votes )

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

Computer organization and architecture designing for performance

Authors: william stallings

8th edition

136073735, 978-0136073734

More Books

Students also viewed these Programming questions

Question

What is the difference between big endian and little endian?

Answered: 1 week ago