N_ROWS=3 N_COLS=5 .text main: # locals # $t0 i (row) # $t1 j (col) li $t0, 0 # int i = 0; loop1: bge $t0, N_ROWS, end1 # if (i >= 3) goto end1; li $t1, 0 # int j = 0; loop2: bge $t1, N_COLS, end2 # if (j >= 5) goto end2; # i is row index # j is col index mul $t2, N_COLS, $t0 # (offset = N_COLS * i + j) * 4 add $t2, $t2, $t1 mul $t2, $t2, 4 li $v0, 1 # printf("%d", numbers[i][j]); lw $a0, numbers($t2) 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