;; This program reads in a sequence S of postive integers, ;; terminated by a non-positive integer, then prints out ;; the floor of the average of S allocate-registers calculate sum n zero one loop x test avg li calculate Lcalculate li sum 0 li n 0 li zero 0 li one 1 li loop Lloop Lloop: read x sgt test x zero jeqz test calculate add n n one add sum sum x j loop Lcalculate: div avg sum n write avg halt