User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 426,634 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 1,561 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: 1543 | Replies: 1
Reply
Join Date: Dec 2007
Posts: 8
Reputation: therealsolitare is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
therealsolitare therealsolitare is offline Offline
Newbie Poster

Two dimensional Arrays in MIPS

  #1  
Dec 2nd, 2007
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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Two dimensional Arrays in MIPS

  #2  
Dec 2nd, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 12:42 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC