Answered step by step
Verified Expert Solution
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 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
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