•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 402,521 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,666 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 1272 | Replies: 1
![]() |
•
•
Join Date: Dec 2007
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,839
Reputation:
Rep Power: 11
Solved Threads: 189
A 1D array is just a contiguous list of values.
A 2D array is just a contiguous list of 1D arrays.
I.e.
That's how we think about it, with those nice line breaks between rows. However, it really looks like this in memory:
So to calculate a position as (row, col):
Hope this helps.
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
[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) +colHope this helps.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Two-Dimensional Arrays (Assembly)
Other Threads in the Assembly Forum
- Previous Thread: User Input (scanf) in SPARC?
- Next Thread: Simple Assembly Question on Strings



Linear Mode