# square array of ints and then print array # register use # - $t0: int i # - $t1: int n # - $t2: int m # - $t3: int square # - $t5..$t7: temporary results main: li $t0, 0 # int i = 0; loop_0: bge $t0, 5, end_0 # if (i >= 5) goto end_0; la $t5, numbers # int m = numbers[i]; mul $t6, $t0, 4 add $t7, $t5, $t6 lw $t2, 0($t7) mul $t3, $t2, $t2 # int square = m * m; sw $t3, 0($t7) # numbers[i] = square; addi $t0, $t0, 1 # i++ b loop_0 # goto loop_0 end_0: li $t0, 0 # int i = 0; loop_1: bge $t0, 5, end_1 # if (i >= 5) goto end_1; la $t5, numbers # int n = numbers[i]; mul $t6, $t0, 4 add $t7, $t5, $t6 lw $t1, 0($t7) move $a0, $t1 # printf("%d", n); li $v0, 1 syscall li $a0, '\n' # printf("%c", '\n'); li $v0, 11 syscall addi $t0, $t0, 1 # i++ b loop_1 # goto loop_1 end_1: li $v0, 0 # return 0 jr $ra .data numbers: # int numbers[10] = { 3, 9, 27, 81, 243}; .word 3, 9, 27, 81, 243