Hey everyone,

How do two-dimensional arrays work in MIPS? I've found a couple of sites that have told me how to set up a multi-dimensional array, but they aren't really that clear on how to access the data on the inside.

My array is set up as such:
board:
.word 0:21
.word 0:21
and so forth, until I've hit the right number of columns and rows.

How do I access the data so I can change it? This si going into my Othello program, so I need to be able to set up the board with the row and column names, and then be able to change the data on the inside as the game progresses.

Thanks!

A 1D array is just a contiguous list of values.
A 2D array is just a contiguous list of 1D arrays.
I.e.

[0][1][2][3][4][5][6][7]  :row 1
[8][9][A][B][C][D][E][F]  :row 2
[0][1][2][3][4][5][6][7]  :row 3
[0][1][2][3][4][5][6][7]  :row 4
[0][1][2][3][4][5][6][7]  :row 5
[0][1][2][3][4][5][6][7]  :row 6
[0][1][2][3][4][5][6][7]  :row 7

That's how we think about it, with those nice line breaks between rows. However, it really looks like this in memory:

[0][1][2][3][4][5][6][7][8][9][A][B][C][D][E][F][0][1]...
 ^row 1                  ^row 2                  ^row 3

So to calculate a position as (row, col): beginning address +(row *num_columns) +col Hope this helps.