Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer in the form given and show your work, thanks! Come up with an algo

ID: 3862586 • Letter: P

Question

Please answer in the form given and show your work, thanks!

Come up with an algorithm that does the following things: It calculates the sum of the integers present in an array of size 100. The array starts at the memory location starting from 0 times 4000, and the array elements are present in consecutive memory locations. The final sum is stored in the following way: a) If the final sum is positive or zero, it is stored in the memory location 0 times 3050. b) If the final sum is negative, it is stored in the memory location 0 times 3051. Terminate. Your solution should use a looping construct. a) Show the algorithm as a flowchart by decomposing it into its basic constructs. b) Convert the above algorithm to an LC-3 program. Write the program in LC-3 binary code. Comment each line of code and submit the binary code as a *.bin file to the dropbox. The program should start at memory location times 3000.

Explanation / Answer

Algorithm Array Sum
Input: nonnegative integer 100, and array A[1],A[2],...,A[100]
Output: sum of the 100 integers in array A
Algorith Body:
j:=1
sum:=0
while j<100
      sum := sum + a[J]
      j:=j+1
end while
end Algorithm Array Sum
if sum>=0

store it at 0x3050

else at 0x3051