summaryrefslogtreecommitdiffstats
path: root/Aufgabe6/sum.asm
blob: aa029f45cbd9ab10117850d5f794c74162bd6be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#
# print sum of input numbers
#
      ld    zero    # initialize sum to zero
      st    sum
loop  get           # read a number
      jz    done    # no more input if number is zero
      add   sum     # add in accumulated sum
      st    sum     # store new value back in sum
      j     loop    # go back and read another number

done  ld    sum
      put           # print sum
      halt          # stop program execution

zero  const 0       # constant
sum   const         # variable