# program reads integers and adds them in the loop, 
# it stops when 0 is read, printing out the sum at that point

main:                            # begin of assembly program consisting only of text segment
       li      $a0,  0           # pseudoinstruction: move immediate to dest
loop:  
       li      $v0,  5           # system call read integer code in $v0
       syscall                   # system call: feature of SPIM, not MIPS
       add     $a0, $a0, $v0     # in $v0 read integer
       bne     $v0, $zero, loop  # if not 0 back to loop
       li      $v0,  1           # print integer system code to $v0
       syscall                   # proper printing
       li      $v0,  10          # exit program system code in $v0
       syscall                   # exit program

