# print a 2d array # i in $t0 # j in $t1 # $t2..$t6 used for calculations main: li $t0, 0 # int i = 0; loop1: bge $t0, 3, end1 # if (i >= 3) goto end1; li $t1, 0 # int j = 0; loop2: bge $t1, 5, end2 # if (j >= 5) goto end2; la $t2, numbers # printf("%d", numbers[i][j]); mul $t3, $t0, 20 add $t4, $t3, $t2 mul $t5, $t1, 4 add $t6, $t5, $t4 lw $a0, 0($t6) li $v0, 1 syscall li $a0, ' ' # printf("%c", ' '); li $v0, 11 syscall addi $t1, $t1, 1 # j++; b loop2 # goto loop2; end2: li $a0, '\n' # printf("%c", '\n'); li $v0, 11 syscall addi $t0, $t0, 1 # i++ b loop1 # goto loop1 end1: li $v0, 0 # return 0 jr $ra .data # int numbers[3][5] = {{3,9,27,81,243},{4,16,64,256,1024},{5,25,125,625,3125}}; numbers: .word 3, 9, 27, 81, 243, 4, 16, 64, 256, 1024, 5, 25, 125, 625, 3125