Question: Show me the steps to solve 4 . 5 . 4 Summing an Integer Array There's hardly any task more common in beginning programming than

Show me the steps to solve 4.5.4 Summing an Integer Array
There's hardly any task more common in beginning programming than calculating the sum of
the elements in an array. In assembly language, you would follow these steps:
Assign the array's address to a register that will serve as an indexed operand.
Initialize the loop counter to the length of the array.
Assign zero to the register that accumulates the sum.
Create a label to mark the beginning of the loop.
In the loop body, add a single array element to the sum.
Point to the next array element.
Use a LOOP instruction to repeat the loop.
Steps 1 through 3 may be performed in any order. Here's a short program that sums an array of
16-bit integers.
; Summing an Array (SumArray.asm)
.386
.model flat,stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
.data
intarray DWORD 10000h,20000h,30000h,40000h
.code
main PROC
mov edi,OFFSET intarray ; 1: EDI = address of intarray
mov ecx,LENGTHOF intarray ; 2: initialize loop counter
mov eax,0 ; 3: sum =0
L1:
add eax, [edi]
add edi,TYPE intarray ; 6: point to next element
loop L1
; 7: repeat until ECX =0
invoke ExitProcess,0
main ENDP
END main
Do program #3 on page 137 at the end of Chapter 4. This is called "Summing the
Gaps between array Values."
I will want an critical thinking documentation, the program listing -- upload the .asm
and the .Ist of the program run. Also, make a copy of the register window with the
answers in it. I would put the sum in a register for viewing.
Write a program with a loop and indexed addressing that calculates the sum of all the
gaps between successive array elements. The array elements are doublewords,
sequenced in nondecreasing order. So, for example, the array {0,2,5,9,10} has gaps
2,3,4, and 1, whose sum equals 10.
Show me the steps to solve 4 . 5 . 4 Summing an

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 Programming Questions!