Intermediate

Array Sum

Sum the elements of an array and print the result.

Write a program that sums the elements of a predefined array and prints the result as a single ASCII digit.

Array: {2, 4, 1, 3} (sum = 10... but 10 is two digits)
Let's use: {1, 2, 1, 2} (sum = 6)

Requirements:
• Sum the 4 elements starting at label ARRAY

• The count of elements is stored at label COUNT

• Print the sum as a single ASCII digit

• Halt after printing

Data layout:

COUNT .FILL #4
ARRAY .FILL #1
      .FILL #2
      .FILL #1
      .FILL #2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15