The below assembly program adds up a list of n numbers, where the size n is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Computer organization and architecture designing for performance
ISBN: 978-0136073734
8th edition
Authors: william stallings
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Let f: RR be a differentiable function such that its derivative f' is continuous and f(n) = 6. If F: [0, 1 by F(x) = f(t)dt, , and if ] R is defined (f'(x)+F(x)) cosx dx = 2 0 then the value of f(0)...
-
Based on your experience with meetings at your current or previous job, what would you do to improve the effectiveness of business meetings?
-
The economies of scale curve in Figure can be represented algebraically in the equation: Average costs = a + bQ + cQ 2 ; where Q is the quantity produced by a firm, and a, b, and c are coefficients...
-
Circuit Board Systems (CBS) has the following data: Assets: $\$ 100,000$; Profit margin: $6.0 \%$; Tax rate: $4.0 \%$; Debt ratio: $40.0 \%$; Interest rate: 8.0\%: Total assets turnover: 3.0. What is...
-
The following income statements were drawn from the annual reports of Pierro Sales Company. The president's message in the company's annual report stated that the company had implemented a strategy...
-
A lake with a fixed carrying capacity contains a certain fish population. The fish population in the lake has a growth rate that is proportional to its size when the population is very small relative...
-
A circle with a radius 3 cm long is inscribed within a square (as shown below) Point A starts at the 3o'clock position and moves CCW along the circle Point B is fixed at the bottom-left corner of the...
-
A company would like to borrow money at the stated annual interest rate (or APR) of 15%, compounded daily. In general, when the interest compounding frequency within a year is lower, the lower...
-
The same study found that \(y=10\) out of \(n=174\) samples identified as having a heavy environmental impact from pastoral (sheep) farms contained Giardia cysts. (a) What is the distribution of...
-
A mass of \(10 \mathrm{~kg}\) of water at \(0^{\circ} \mathrm{C}\) is brought into contact with a large heat reservoir at \(100{ }^{\circ} \mathrm{C}\). a. When the water has reached \(100^{\circ}...
-
A system contains a fluid at a temperature of \(70^{\circ} \mathrm{C}\) and 1 bar. It undergoes a reversible process during which the temperature of the system remains constant. Given that the heat...
-
A mass of a liquid, \(m\), at temperature, \(T_{1}\), is mixed with an equal mass of the same liquid at temperature, \(T_{2}\). The system is thermally insulated. Show that the change of entropy of...
-
An incompressible liquid of specific volume \(v_{l}\), is in equilibrium with its own vapour and an inert gas in a closed vessel. The vapour obeys the law \[p(v-b)=\Re T\] Show that \[\ln...
-
I love to eat cookies. More cookies! Thats mine! Put it in box. He does it. Car! Car going! Him drives it. Drive car there! Is it going? Its mine! Its going fast. The car is going fast. It has a fast...
-
What is the difference between big endian and little endian?
-
A non pipelined processor has a clock rate of 2.5 GHz and an average CPI (cycles per instruction) of 4. An upgrade to the processor introduces a five-stage pipeline. However, due to internal pipeline...
-
An earlier version of the IBM mainframe, the S/390 G4, used three levels of cache.As with the z990, only the first level was on the processor chip [called the processor unit (PU)].The L2 cache was...
-
Consider the multiple linear regression model fit to the baseball data in Problem 3.41. Problem 3.41 Consider the 2016 major league baseball data in Table B.22. While team ERA was useful in...
-
Consider the simple linear regression model fit to the rental price data from Problem 2.36. Data From Problem 2.36 Table B.24 contains data on median family home rental price and other data for 51 US...
-
Consider the multiple linear regression model fit to the rental price data in Problem 3.42. Problem 3.42 Table B.24 contains data on median family home rental price and other data for 51 US cities....
Study smarter with the SolutionInn App