二维数组在MIPS [英] 2D Array in MIPS

查看:1565
本文介绍了二维数组在MIPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索,并在本网站和我找不到实施MIPS二维数组的一个很好的例子。我希望能够看到的是如何去通过阵列,以地方数据在特定的索引以及如何打印出数组如下所示的例子。

比如一个5x5的阵列,其中$将是各项指标的数据。

  A B C D E
$ 1 $ $ $ $
2 $ $ $ $ $
3 $ $ $ $ $
4 $ $ $ $ $
5 $ $ $ $ $


解决方案

您可以建立一个二维数组中的一维数组的条款。你只需要正确映射从一维数组的二维数组元素。这个网站有图片:

<一个href=\"http://www.plantation-productions.com/Webster/www.artofasm.com/Windows/HTML/Arraysa2.html#1010609\" rel=\"nofollow\">http://www.plantation-productions.com/Webster/www.artofasm.com/Windows/HTML/Arraysa2.html#1010609

您可以使用标准格式寻址每个单元格。例如:

  A B C D E1 0 1 2 3 4
2 5 6 7 8 9
3 10 11 12 13 14
4 15 16 17 18 19
5 20 21 22 23 24

您应该能看到图案:)在一般情况下,如果有M列和N行,在行i,j列(零索引)可以在点被访问的小区i * M + J - 1

I've searched online and on this site and I can not find a good example of implementing a 2D Array in MIPS. I would like to be able to see an example of how to go through the array in order to place data at a specific index and how to print the array out like shown below.

Such as a 5x5 array where $ would be the data in each index.

  a b c d e
1 $ $ $ $ $
2 $ $ $ $ $
3 $ $ $ $ $
4 $ $ $ $ $
5 $ $ $ $ $

解决方案

You can set up a 2D array in terms of a 1D array. You just need to correctly map elements from the 1D array to the 2D array. This site has pictures:

http://www.plantation-productions.com/Webster/www.artofasm.com/Windows/HTML/Arraysa2.html#1010609

You can use a standard format for addressing each cell. For example:

      a  b  c  d  e

1     0  1  2  3  4
2     5  6  7  8  9
3    10 11 12 13 14
4    15 16 17 18 19
5    20 21 22 23 24

You should be able to see the pattern :) In general, if there are M columns and N rows, the cell at row i, column j (zero-indexed) can be accessed at point i * M + j - 1

这篇关于二维数组在MIPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆