# Print the values of an array until a zero value is found. # # Here we load the base address of the array # into a register, load the value stored at # that address, and add 4 (the size of a word) # to the address to get to the next element. .data array: .word 55 .word 66 .word 77 .word 0 nl: .asciiz "\n" .text # $t0 holds address of current element # $a0 holds current data value main: la $t0,array loop: lw $a0,($t0) # Load data value beq $a0,0,done # while ($a0!=0) do li $v0,1 # print data value syscall la $a0,nl # print nl li $v0,4 syscall add $t0,4 # $t0 points to next array elmt. b loop # end while done: li $v0,10 # exit syscall