如何在 MIPS 中更新数组?
我正在尝试创建一个数组,然后根据需要更新某些单元格的值。据我所知,使用堆栈框架将是最好的方法,但我无法让它工作。有人能指出我正确的方向吗?
谢谢!
I'm trying to make an array, and then update the values of certain cells if needed. From what I know, using the Stack Frame would be the best approach, but I can't get it to work. Anyone able to point me in the right direction?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该已经很好地理解了数组操作在 C 等语言中的工作原理。
如果您想将数组放入当前堆栈帧中并在那里对其进行操作(并了解这样做的好处和问题),那么您应该执行以下操作:
$sp
) 的当前值。您将使用它作为指向数组开头的指针。将其存储在另一个寄存器中。$sp
) 增加数组的字节数。这将为您提供足够的工作空间。sw
指令在数组中的该地址存储一个字,并使用lw
加载一个字。You should already have a good understanding of how array manipulation works in a language like C.
If you want to put an array in the current stack frame, and manipulate it there (and understand the benefits and issues of doing so), then you should do the following:
$sp
). You will use this as the pointer to the start of the array. Store it in another register.$sp
) by however many bytes the array is. This will give you enough space to work.sw
instruction to store a word in the array at that address, and uselw
to load a word.