# Compute average of four values in memory (no memory offset). # # This program averages four values in memory. # # $5 = address, $7 = sum, $8 = input Array: .word 11, 22, 33, 44, 00 Avg: addi $5, $0, Array # initialize array ptr lw $7, 0($5) # load first element addi $5, $5, 4 # increment ptr lw $8, 0($5) # load the next element add $7, $7, $8 # add input to sum addi $5, $5, 4 # increment ptr lw $8, 0($5) # load the next element add $7, $7, $8 # add input to sum addi $5, $5, 4 # increment ptr lw $8, 0($5) # load the next element add $7, $7, $8 # add input to sum sra $7, $7, 2 # divide by four addi $5, $5, 4 # increment ptr sw $7, 0($5) # store average in memory jr $31 # return to caller